Reputation: 2705
I want to have one instance of the class C
in my program, and I defined a singleton method get_instance
as follows.
class C {
static map<int, map<int, int> > t;
public:
static C& get_instance() {
static C instance;
return instance;
}
private:
C() {};
};
and I tried to get a distance using this method.
static C& rt = C.get_instance();
However, I am getting an error
src/C.cpp:115:41: error: expected primary-expression before ‘.’ token
static C& rt = C.get_instance();
Am I doing something wrong?
The Singleton design is from C++ Singleton design pattern
Upvotes: 1
Views: 1613