Hi, I have a question here
Code:
#include<iostream>
using namespace std;
class Counted{
public:
Counted():id(count++){ cout << id << endl; }
~Counted();
private:
static int count;
int id;
};
Counted::~Counted()
{
cout << "Being destroyed" << endl;
}
void main()
{
Counted c;
}
When i compile it ,it's OK!
When i excute it ,the following error message:
Linking...
HW_Ch13_1.obj : error LNK2001: unresolved external symbol "private: static int Counted::count" (?count@Counted@@0HA)
Debug/HW_Ch13_1.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
HW_Ch13_1.exe - 2 error(s), 0 warning(s)
so, could anyone tell me why??thx~~~