e6694811
asked on
Serializing a static data member
Is there any chance I can serialize a static data member ?
Consider the following case.
class CB:public CA
{
protected:
static UINT m_number;
..... (more data menbers)
public:
..... (some functions)
Serialize (Carchive &ar);
....
}
The function serialize is defined as follows:
void CB::Serialize(CArchive &ar)
{
if (ar.IsStoring())
ar <<m_number;
else
ar >>m_number;
CA::Serialize(ar);
}
m_number is used to store the amount of objects of the same class.
When linking the following error occurs:
rror LNK2001: unresolved external symbol "protected: static unsigned int CB::m_number" (?m_number@CB@@1IA)
Any help ? thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I think I have to ommit the word "static" ,right ?
Right.
static UINT CB::m_number = 0;