Vote count:
0
When I try to compile the code below I get an error?
class A {
private:
static A* Aptr[5];
public:
static int A_count;
A() {
Aptr[A_count] = this;
}
};
int A::A_count = 0;
int main() {
A a_;
A b_;
return 0;
}
Using g++ I get the following error:
/tmp/ccrp4BGg.o: In function `A::A()':
try.cpp:(.text._ZN1AC2Ev[_ZN1AC5Ev]+0x18): undefined reference to `A::Aptr'
collect2: error: ld returned 1 exit status
Why?
asked 29 secs ago
Aucun commentaire:
Enregistrer un commentaire