关于c++中类的继承与派生

2014-11-24 09:13:56 · 作者: · 浏览: 0

c++class
[cpp]
#include
using namespace std;
class A{
public:
int x;
A(int a,int b){
a=x;
b=u;}
void prt(){
cout< private:
int u;
};
class B:public A{
public:

B(int a,int b,int c):
A(a,b){
y=c;}
int y;
void prt(){
cout<<"A::x=:"< A::prt();
cout<<" B::y=:"< }
};
int main(){
B b(1,2,3);
b.prt();
cout< }

为什么x的值不是1呢