What is the problem with this code?

Posted by eSKay on Stack Overflow See other posts from Stack Overflow or by eSKay
Published on 2010-05-19T18:05:59Z Indexed on 2010/05/19 18:10 UTC
Read the original article Hit count: 109

Filed under:
|
|
#include<stdio.h>

class A { public: int a;};
class B: public A { 
public:
    static int b;
    B(){
        b++;
        printf("B:%d\n",b);
    }   
};

int main() {

    A* a1 = new B[100];
    A* a2 = new B();
    return 0;
}

Error:

In function `main':
undefined reference to `B::b'
undefined reference to `B::b'
undefined reference to `B::b'
undefined reference to `B::b'

© Stack Overflow or respective owner

Related posts about c

    Related posts about c++