Hey all,
I've decided to try out the singleton method. Unfortunately I'm running into some problems.
Whenever I try to get an instance of my object, I get this error:
cannot call member function ‘angleInputLogic* angleInputLogic::getInstance(ImpressionistDoc*)’ without object
Where I'm calling from a static void method
void ImpressionistUI::cb_angleSampleChoice(Fl_Widget* o, void* v)
{
...
angleInputLogic* angleLogic;
angleLogic = angleInputLogic::getInstance(pDoc);
}
And my singleton class looks like:
static angleInputLogic* angleInputLogicInstance;
int angleSampleType;
ImpressionistDoc* pDoc;
angleInputLogic * getInstance(ImpressionistDoc* pDoc) {
if (!angleInputLogicInstance)
angleInputLogicInstance = new angleInputLogic(pDoc);
return angleInputLogicInstance;
}
angleInputLogic::angleInputLogic(ImpressionistDoc* pDoc) {
angleSampleType = 0;
}
Any ideas? Thanks in advance.
getInstance should be a static method. Think about it: you want to get an instance (so you currently do not have one).
Also, I assume that the constructor(s) and assignment operator are private.
Last edited on