Deriving from Two Different Classes - C++ Class

C++ examples for Class:Inheritance

Description

Deriving from Two Different Classes

Demo Code

#include <iostream>
using namespace std;

class Mom {//  ww w.j a va2s. co m
public:
    void Brains() {
        cout << "I'm smart!" << endl;
    }
};
class Dad {
public:
    void Beauty() {
        cout << "I'm beautiful!" << endl;
    }
};
class Derived : public Mom, public Dad {
};
int main(int argc, char *argv[])
{
    Derived child;
    child.Brains();
    child.Beauty();
    return 0;
}

Result


Related Tutorials