C++.阅读程序,写出运行结果,求大神 5
#include<iostream.h>运行结果:classA{protected:intx;public:A(intx){A::x=x;cout<<"classA"<<...
#include <iostream.h>
运行结果:
class A{
protected: int x;
public: A(int x)
{A::x=x;
cout<<"class A"<<endl;
}};
class B{
private: A a1;
public: B(int x):a1(x){cout<<"class
B"<<endl;}
};
class C:public B{
private: A a2;
public: C(int x):B(x),a2(x){cout<<"class C"<<endl;}
};
class D:public C{
public: D(int x):C(x){cout<<"class
D"<<endl;}
}; 展开
运行结果:
class A{
protected: int x;
public: A(int x)
{A::x=x;
cout<<"class A"<<endl;
}};
class B{
private: A a1;
public: B(int x):a1(x){cout<<"class
B"<<endl;}
};
class C:public B{
private: A a2;
public: C(int x):B(x),a2(x){cout<<"class C"<<endl;}
};
class D:public C{
public: D(int x):C(x){cout<<"class
D"<<endl;}
}; 展开
3个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询