第10週第11週項目1読解プログラム(5)

847 ワード

/*
*Copyright (c) 2016,         
*All rights reserved.
*     :
*       :   
*     : 2016 5 9 
*      : v1.0
*
*     :      
*     :
*     :
*/
#include <iostream>
using namespace std;
class A
{
protected:
    int a,b;
public:
    A(int aa, int bb):a(aa), b(bb) {}
    void printA(){
        cout<<"a: "<<a<<"\tb: "<<b<<endl;
    }
};
class B: public A
{
    int c;
public:
    B(int aa, int bb, int cc):A(aa,bb),c(cc) {}
    void printB()
    {
       cout<<"a: "<<a<<"\tb: "<<b<<"\tc: "<<c<<endl;
    }
};
int main()
{
    A a(1,1);
    B b(2,3,4);
    a=b;
    a.printA();
    b.printA();
    b.printB();
    //             
    return 0;
}

実行結果:
a:2b:3
a:2b:3
a:2b:3c:4