我有一个无法在其它类中创建类对象的假想。 假想如下:
class base
{
public:
base();
~base();
int getbase(void){return baseVar;}
void setbase(int arg){baseVar = arg;}
private:
int baseVar;
};
class derived1 : public base
{
public:
derived1();
~derived1();
int getbase(void);
void setbase(int arg);
private:
int derVar1;
};
class derived2 : public base
{
public:
derived2();
~derived2();
int getbase(void);
void setbase(int arg);
private:
int derVar2;
};
class container
{
public:
container();
~container();
derived1 derObj1;
derived2 derObj2;
private:
int containerVar;
};
class usage
{
public:
usage();
~usage();
private:
container containerObj; // compilation error
int usegeVar;
};
compilation error is : error C2146: syntax error : missing ; before identifier containerObj error C4430: missing type specifier - int assumed. Note: C++ does not support default-int error C4430: missing type specifier - int assumed. Note: C++ does not support default-int i am using vc++
我请求一些人如何纠正这一汇编错误?