Mail Archives: djgpp/1997/05/22/11:34:33
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
- Raw text -