Reputation: 1
I am new to c++ and am trying a basic factory pattern in C++11 but is failing with error: 'X' does not refer to a value. Any suggestions?
Test Code: X instance = X.createNewInstance();
Original Class
class X
{
public:
static X createNewInstance() {
return X();
};
void foo() ;
private:
X(){};
};
Upvotes: 0
Views: 52
Reputation: 14224
You have to call static member functions with ::
X instance = X::createNewInstance();
Upvotes: 1