c++class
[cpp]
#include<iostream>
using namespace std;
class A{
public:
int x;
A(int a,int b){
a=x;
b=u;}
void prt(){
cout<<cout<<x<<endl;}
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::x<<endl;
A::prt();
cout<<" B::y=:"<<B::y<<endl;
}
};
int main(){
B b(1,2,3);
b.prt();
cout<<b.x<<endl;
}
為什麼x的值不是1呢