我现在想让一些类共享一位图,我写成这种形式。
class myClass
{
private:
……
static CBitmap m_pic;
static CString m_str;
};静态变量是不是一定要初始化???
m_str初始化还好办
CString myClass::m_str="abcd";可是m_pic呢??好像根本就没有"="操作!!!咋办
class myClass
{
private:
……
static CBitmap m_pic;
static CString m_str;
};静态变量是不是一定要初始化???
m_str初始化还好办
CString myClass::m_str="abcd";可是m_pic呢??好像根本就没有"="操作!!!咋办
{
private:
static int count;public:
void countVal()
{
cout<<count<<endl;
}
void operator =(int b)
{
count=b;
}
};int Point::count =1;class Rect
{
private:
static Point a;
public:
void countVal()
{
a.countVal();
}
};void Rect::a=5;void main()
{
Point a;
a.countVal();
a=8;
a.countVal(); Rect b;
b.countVal();}