
Initializing a static object
C++ standard 9.2/4: A member-declarator can contain a
constant-initializer only if it declares a static member (9.4) of
integral or enumeration type. The OP says MUTEX is a class with a
constructor, so it cannot be an integral or enumeration type.
--
With best wishes,
Igor Tandetnik
"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken
Quote:
> C++ standard support code like this:
> class ATOMIC{
> ...
> private:
> static MUTEX Mutex=NULL:
> };
> I don't know about VC 7, but VC++ 6.0 doesn't support this feature.
> So, you have to add
> MUTEX ATOMIC::Mutex=NULL;
> into your cpp file.
> > Hi,
> > If I have something like:
> > class ATOMIC {
> > .
> > .
> > .
> > private:
> > static MUTEX Mutex;
> > }
> > How do I intialize user defined static members.
> > MUTEX has a constructor MUTEX(void). I am getting a link
> > error:
> > atomic.obj : error LNK2001: unresolved external
> > symbol "private: static class MUTEX ATOMIC::Mtx"
> > Thanks,
> > Vikas