So I have a simple class with an overloaded function operator. I also have a static vector in there. I'm trying to add values to the vector through the function operator, but it doesn't seem to be working.
class ExampleClass
{
private:
static std::vector<std::string> exampleVector;
public:
void operator () (std::string input)
{
exampleVector.push_back(input);
}
};
int main()
{
ExampleClass exampleObject;
exampleObject("Hello World!");
}
The error I'm getting is a "unresolved external symbol":
error LNK2001: unresolved external symbol "private: static class std::vector<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::allocator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > > ExampleClass::exampleVector" (?exampleVector@ExampleClass@@0V?$vector@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@A)
I have no clue what what means. But my code seems to work fine without the static
keyword. So what am I missing here? Thanks.