#include
class A
{protected:
int a,b;
public:
A(){a=0;b=0;};
A(int x,int y):a(x),b(y){};
void seta();
};
class B: public A
{private:
int c;
public:
B(){a=0;b=0;c=0;};
B(int x,int y,int z):a(x),b(y),c(z){};
void setb();
};
void A::seta()
{int x,y;
cin>>x>>y;
a=x;
b=y;
}
void B::setb()
{int x,y,z;
cin>>x>>y>>z;
a=x;
b=y;
c=z;
}
D:\我的文档\桌面\新建文件夹\Cpp2.cpp(15) : error C2614: 'B' : illegal member initialization: 'b' is not a base or member
D:\我的文档\桌面\新建文件夹\Cpp2.cpp(15) : error C2614: 'B' : illegal member initialization: 'a' is not a base or member
不能继承 a,b 数据成员吗?
|