<分区>
我有类 A
和方法 display()
。我创建了一个结构 B
,其中包含一个类型为对象 A
的静态变量:
class A{
public :
void display()
{
cout << "in A " << endl;
}
};
typedef struct B{
static A a;
} bb;
//B::a.display();
int main() {
bb b;
bb::a.display();
return 0;
}
现在我在尝试访问 a
时遇到错误。
在这种情况下如何定义静态对象?