If i try to initialize obj_s
it asks me to make it const
- and i cant do that for i have to keep count of my Created Objects.
#include<iostream>
class A
{
static int obj_s=0;
public:
A(){ ++obj_s;cout << A::obj_s << "
Object(s) Created
"; }
};
int main()
{
A a,b,c,d;
}
The code below keeps giving me the following error:
[Linker error] undefined reference to `A::obj_s'
See Question&Answers more detail:os