I have a class with a static char array.
The size of the array is given to me in argv.
I want to do somthing like this:
class ABC {
public:
static char *buffer;
ABC(int size) {
ABC::buffer = new char[size];
}
}
// in other file:
ABC tempVar(atoi(argv[1]));
but this doesn't seem to work. I get errors like:
Error 2 error LNK2001: unresolved external symbol "public: static char * ABC::buffer" (?buffer@ABC@@2PADA) gpslib.lib
How can I fix this?
atoi. Usestd::stoi(introduced by C++11).std::stoiwill let you know if the argument is invalid (or there is overlow), whilestd::atoiwill be silent.