Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #10053

Re: Am I not confident enuff to do this?

From "Thomas J. Gritzan" <phygon_antispam@gmx.de>
Newsgroups comp.lang.c++
Subject Re: Am I not confident enuff to do this?
Date 2011-09-12 03:31 +0200
Organization news.netcologne.de
Message-ID <j4jne9$j2h$1@newsreader4.netcologne.de> (permalink)
References <rchq57132mpjq7hc75ccb5ivcfin294vl5@4ax.com>

Show all headers | View raw


Am 30.08.2011 22:31, schrieb Heck:
> I was given a programming question on a tech test that made me doubt
> myself.  It seemed too simple.  Did I miss something?  This is the
> text of the question exactly as I got it:
>
> Without defining any new variable or passing an argument to function,
> I want you to be able to increment a number every time this method is
> called. (Chose a language of your choice and write a fully compilable
> method)
>
> At the very least, this is a poorly framed question.

Quite poorly.

I guess the "without defining any new variable" is meant per call (or 
whatever), so a static variable would be ok:

int inc() {
    static int i = 0;
    return ++i;
}

But since they want a "fully compilable method", make a closure in a 
/compilable/ OOP language with closures.

-- 
Thomas

Back to comp.lang.c++ | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

Am I not confident enuff to do this? Heck <heckja_in@ordertostymieharvestersverizon.net> - 2011-08-30 16:31 -0400
  Re: Am I not confident enuff to do this? Paavo Helde <myfirstname@osa.pri.ee> - 2011-08-30 15:50 -0500
    Re: Am I not confident enuff to do this? Heck <heckja_in@ordertostymieharvestersverizon.net> - 2011-08-30 23:50 -0400
      Re: Am I not confident enuff to do this? Ian Collins <ian-news@hotmail.com> - 2011-08-31 16:00 +1200
        Re: Am I not confident enuff to do this? "Waldek M." <wm@localhost.localdomain> - 2011-08-31 18:43 +0200
    Re: Am I not confident enuff to do this? Juha Nieminen <nospam@thanks.invalid> - 2011-08-31 06:24 +0000
  Re: Am I not confident enuff to do this? hanukas <jukka@liimatta.org> - 2011-08-31 01:13 -0700
    Re: Am I not confident enuff to do this? Edek <edek.pienkowski@gmail.com> - 2011-08-31 22:55 +0200
  Re: Am I not confident enuff to do this? Krice <paulkp@mbnet.fi> - 2011-09-01 00:00 -0700
    Re: Am I not confident enuff to do this? "hugo_ribeira@hotmail.com" <hugo_ribeira@hotmail.com> - 2011-09-01 03:27 -0700
  Re: Am I not confident enuff to do this? James Kanze <james.kanze@gmail.com> - 2011-09-01 15:56 -0700
    Re: Am I not confident enuff to do this? red floyd <no.spam.here@its.invalid> - 2011-09-01 17:01 -0700
      Re: Am I not confident enuff to do this? Joe Greer <jgreer@doubletake.com> - 2011-09-02 15:34 +0000
        Re: Am I not confident enuff to do this? Paavo Helde <myfirstname@osa.pri.ee> - 2011-09-02 10:47 -0500
  Re: Am I not confident enuff to do this? Daniel Bradley <daniel@bradley.mx> - 2011-09-07 14:58 +0000
  Re: Am I not confident enuff to do this? "Thomas J. Gritzan" <phygon_antispam@gmx.de> - 2011-09-12 03:31 +0200

csiph-web