Sender: brozzis AT mag00 DOT cedi DOT unipr DOT it Message-Id: <33846685.79AA@mag00.cedi.unipr.it> Date: Thu, 22 May 1997 17:30:13 +0200 From: Stefano Brozzi Mime-Version: 1.0 To: Bryan Murphy Cc: djgpp AT delorie DOT com Subject: Re: C++ problem References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Precedence: bulk Bryan Murphy wrote: > > >in C++ is possible to have default arguments to member functions > >(i.e. int foo( int bar = 3 ) {...} ) . > >Could I have, as default value, the value of a member variable ? > >(i.e. something like: > > > >struct Question { > > int zoo; > > Question() : zoo(3) {} // this makes evrybody happy ;) > > int foo( int bar = Question::zoo ); > >} > > > > Question: Why not just make > > int foo(int bar=3); > > the default? It does the exact same thing as this snipet of code you've > shown us. Am I missing something here? Your method might work if > you make zoo static, but I'm still not even sure of it or it's need. I want zoo to be a variable. In this example I assigned 3 to zoo to avoid a : "Ehi, you are handling uninit. vars" answer. And if I declare it static: s.cc:5: field `int Question::zoo' is static; only point of initialization is its declaration where line 5 is Question() : zoo(3) {} Ste