Serializing a static data member

 Is there any chance I can serialize a static data member ?

 Consider the following case.

 class CB:public CA
   static UINT m_number;

..... (more data menbers)


..... (some functions)

  Serialize (Carchive &ar);


The function serialize is defined as follows:

void CB::Serialize(CArchive &ar)

    if (ar.IsStoring())
              ar <<m_number;
             ar >>m_number;


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.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

The error has nothing to do with Serialize. You declare the variable but not define it yet.

Put the following line in your .cpp file.

static UINT class CB::m_number = 0;


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Sorry, it should read

static UINT CB::m_number = 0;
e6694811Author Commented:

 I think I have to ommit the word "static" ,right ?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.