Problem Static Pointer
Verfasst: 22. März 2011 10:57
Hallo Zusammen.
Ich stehe gerade auf dem Schlauch.
Ich nutze das State Pattern der GoF und will die Zustände als Singelton implementieren.
Leider wird mir beim Linken ein Fehler ausgeworfen.
Meine Spezielle Zustandsklasse:
Die Implementierung der statischen Funktion:
Und die Fehlermeldung:
Linking...
1>DCMotorStateClosing.obj : error LNK2001: unresolved external symbol "public: static class DCMotorStateClosing * DCMotorStateClosing::pInstance" (?pInstance@DCMotorStateClosing@@2PAV1@A)
1>C:\Users\s\Documents\Visual Studio 2008\Projects\uCMotorTest1\Debug\uCMotorTest1.exe : fatal error LNK1120: 1 unresolved externals
Ev sieht jemand den Fehler
Ich stehe gerade auf dem Schlauch.
Ich nutze das State Pattern der GoF und will die Zustände als Singelton implementieren.
Leider wird mir beim Linken ein Fehler ausgeworfen.
Meine Spezielle Zustandsklasse:
Code: Alles auswählen
#include "DCMotorState.h"
class DCMotorStateClosing : public DCMotorState {
public:
static DCMotorStateClosing* pInstance;
static DCMotorState* Instance();
DCMotorStateClosing();
~DCMotorStateClosing();
void open(DCMotor* motor);
void checkTime(DCMotor* motor);
void raiseError(DCMotor* motor);
void closingPositionDetected(DCMotor* motor);
private:
};
Code: Alles auswählen
DCMotorState* DCMotorStateClosing::Instance(){
if(DCMotorStateClosing::pInstance == NULL)
{
DCMotorStateClosing::pInstance = new DCMotorStateClosing();
}
return DCMotorStateClosing::pInstance;
}
Linking...
1>DCMotorStateClosing.obj : error LNK2001: unresolved external symbol "public: static class DCMotorStateClosing * DCMotorStateClosing::pInstance" (?pInstance@DCMotorStateClosing@@2PAV1@A)
1>C:\Users\s\Documents\Visual Studio 2008\Projects\uCMotorTest1\Debug\uCMotorTest1.exe : fatal error LNK1120: 1 unresolved externals
Ev sieht jemand den Fehler