Class base{
public :
static vector<int> _elems;
... How can I use that static one.Must I define it out of the class body again? Or I meet a trouble about a error"Undefine reference to 'base::_elems'"
Class base{
public :
static vector<int> _elems;
... How can I use that static one.Must I define it out of the class body again? Or I meet a trouble about a error"Undefine reference to 'base::_elems'"
You've only declared the static member, never defined it. In your cpp file you need to do this:
vector<int> base::_elems;
You can use it like any other variable. You only need to remember that the static variable is the same for all instances.
Edit: I forgot the defenition. You must define the variable, this can be done from any cpp file, but i recommend to define the variable in the file base.cpp.