M
markww
Hi,
I want all instance of a class type to share one variable, I forgot how
to do that:
class CMyClass {
public:
static int m_nSharedRes;
};
Now can all instances of CMyClass share that one variable, and see the
changes reflected in each instance? Like:
CMyClass a;
CMyClass b;
a.m_nSharedRes = 44;
// Now b can see it as 44 too.
cout << b.m_nSharedRes << endl; // should print 44;
Thanks!
I want all instance of a class type to share one variable, I forgot how
to do that:
class CMyClass {
public:
static int m_nSharedRes;
};
Now can all instances of CMyClass share that one variable, and see the
changes reflected in each instance? Like:
CMyClass a;
CMyClass b;
a.m_nSharedRes = 44;
// Now b can see it as 44 too.
cout << b.m_nSharedRes << endl; // should print 44;
Thanks!