C++マルチ継承

3675 ワード

//c++     

#include <iostream>


using namespace std;

class father
{
private:
    int a;
    int b;
public:
    int c;
    int d;
protected:
    int e;
    int*p;

public:
    void setA(int newA)
    {
        a=newA;
    };
    void showA(void)
    {
        cout<<a<<"father show A"<<endl;
    }
};

class mother
{
private:
    int a;
public:
    void setA(int newA)
    {
        a=newA;
    }
    void showA(void)

    {
        cout<<a<<"mother show A"<<endl;
    }
};

//       
//   
class Son:public father,public mother
{
public:

    void func(void)
    {
        c=9;
        e=10;
    };

private:
    int A;

    void fuc11(void)
    {
        father::c=10;
    };

};
int main(int argc, const char * argv[]) {
    // insert code here...
    std::cout << "Hello, World!
"
; Son son; son.father::setA(9999); son.father::showA(); cout<<endl; son.mother::showA(); // , // ? // , , , // , // // ( + ,) , cout<<sizeof(father)<<endl; cout<<sizeof(son)<<endl; // return 0; }