I have a static variable that I use as a counter and a non-static version of the variable that I use to save the value of the counter at certain events. Here is some code:
Header:
static int UndoID;
int UndoRedoID;
void SetUnsavedChanges();
Class:
At various parts of the class I try something like this:
UndoRedoID = UndoID;
I've tried other things like:
UndoRedoID = myClass:UndoID;
Example comparision:
void myClass::SetUnsavedChanges()
{
if (UndoRedoID != UndoID)
{
cout << "Unsaved";
}
else
{
cout << "Saved";
}
}
This causes me to get linking errors like:
Undefined symbols:
"myClass::UndoID", referenced from:
myClass::SetUnsavedChanges() in myClass_lib.a(myClass.o)
...
Thank you for your help :)
You need to define the static member data, outside the class as:
Let me add one example:
then in
X.cpp
file, you should do this: