> Question 1:
> how can i initialize counter at (A) to 0?
> i replaced (A) with
> static int counter = 0;
>
> and compiler said:
> "ANSI C++ forbids in-class initialization
> of non-const static member `counter'"
>
> Question 2;
> it seems that linker is not able to link object files from
> the source code:
>
To initialize, just add the line
int base::counter = 0;
after the class declaration. It will solve both problems.
- static variable in C++ Yasushi Shoji
- Re: static variable in C++ Ken Dunn
- Re: static variable in C++ mojahed
- Re: static variable in C++ Vitaly Fedrushkov
