I have a class in which I would like to have a static member which is a struct.
for example: .h file:
typedef struct _TransactionLog
{
string Reference;
vector<int> CreditLog;
int id;
}TransactionLog;
class CTransactionLog {
static TransactionLog logInfo;
public:
static void Clear();
static TransactionLog getLog();
};
.cpp file:
void CTransactionLog::Clear()
{
logInfo.Reference = "";
logInfo.CreditLog.clear();
logInfo.id = 0;
}
TransactionLog CTransactionLog::getLog()
{
return logInfo;
}
I get
Description Resource Path Location Type
undefined reference to `CTransactionLog::logInfo' TransactionLog.cpp
Can someone please give me an example how to make this work? Having a static member which is a struct(with stl members), manipulate it with static member methods and include this header in few other parts of the code. This should be used to add logging through the application.