第10週目の項目はプログラムを読むと、プログラムの実行結果を書き出します(3)

905 ワード

/*copyright(c)2016.         
 * All rights reserved,
 *     :text.Cpp
 *   :   
 *     :2016 4 30 
 *    :vc++6.0
 *
 *     :             
 */
#include<iostream>
using namespace std;
class A
{
public:
    A(char *s){cout<<s<<endl;}
};
class B:public A
{
public:
    B(char *s1,char *s2):A(s1)
    {
        cout<<s2<<endl;
    }
};
class C: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){cout<<s4<<endl;}
};
int main()
{
    D d("class A","class B","class C","class D");
    return 0;
}

実行結果:
                class A
                class B
                class C
                class D
                class D