C++.阅读程序,写出运行结果,求大神。
#include<iostream.h>classA{public:A(char*s){cout<<s<<endl;}};classB:virtualpublicA{pu...
#include<iostream.h>
class A{ public: A(char *s){cout<<s<<endl;}
};
class B:virtual public A
{ public: B(char *s1,char
*s2):A(s1){cout<<s2<<endl;}
};
class C:virtual public A
{ public: C(char *s1,char
*s2):A(s1){cout<<s2<<endl;}
};
class D:public B,C
{public:
D(char
*s1,char *s2,char *s3,char *s4)
:B(s1,s2),C(s3,s4),A(s1){cout<<s4<<endl;}
};
void main()
{ D d("class
A","class B","class c","class D");
} 展开
class A{ public: A(char *s){cout<<s<<endl;}
};
class B:virtual public A
{ public: B(char *s1,char
*s2):A(s1){cout<<s2<<endl;}
};
class C:virtual public A
{ public: C(char *s1,char
*s2):A(s1){cout<<s2<<endl;}
};
class D:public B,C
{public:
D(char
*s1,char *s2,char *s3,char *s4)
:B(s1,s2),C(s3,s4),A(s1){cout<<s4<<endl;}
};
void main()
{ D d("class
A","class B","class c","class D");
} 展开
1个回答
展开全部
#include<iostream>
using namespace std;
class A
{
public:
A(char *s){cout<<s<<endl;}
};
class B:virtual public A
{
public:
B(char *s1,char*s2):A(s1){cout<<s2<<endl;}
};
class C:virtual public A
{
public:
C(char *s1,char*s2):A(s1){cout<<s2<<endl;}
};
class D:public B,C
{
public:
D(char*s1,char *s2,char *s3,char *s4):B(s1,s2),C(s3,s4),A(s1){cout<<s4<<endl;}
};
int main()
{
D d("class A","class B","class c","class D");
cin.get();
return 0;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询