这段程序谁能找出错误在哪儿?
这段程序谁能找出错误在哪儿?#include <iostream>
using namespace std;
class counted{
int id;
static int count ;
public:
counted():id(count++){
cout<<id<<endl<<"it's being created"<<endl;
}
~counted(){
cout<<id--<<endl<<"it's being destroyed"<<endl;
}
};
int main(){
counted me;
return 1;
}
MinGW下编译报错为:
--------------------Configuration: 1301 - Debug--------------------
Linking...
D:\MinGWStudio\1301\Debug\1301.o: In function `ZN7countedC1Ev':
D:\MinGWStudio\1301\1301.cpp:(.text$_ZN7countedC1Ev[counted::counted()]+0xa): undefined reference to `counted::count'
D:\MinGWStudio\1301\1301.cpp:(.text$_ZN7countedC1Ev[counted::counted()]+0x10): undefined reference to `counted::count'
collect2: ld returned 1 exit status
1301.exe - 2 error(s), 0 warning(s)