Here is the code:
Code:
#include <string>
#include <iostream>
#include <vector>
using namespace std;
class Person {
private:
static const int _age = 20;
static vector<int> _elems ;
public:
static void getAge();
};
void Person::getAge() {
cout << _age << endl;
//error occure here, _elems.size() can not be resolved.
cout << _elems.size() << endl;
}
int main() {
Person p;
p.getAge();
return 0;
}
The compiler error in Windows is: error LNK2019: unresolved external symbol,
Can any help me why data member "_age" can be accessed but "_elems" failed.
Thanks.