//7A C++ program to explain // Multiple inheritance#include <iostream.h>// first base classclass Vehicle{ public: Vehicle() { cout << "This is a Vehicle" << endl; }};// second base classclass FourWheeler { public: FourWheeler() { cout << "This is a 4 wheeler Vehicle" << endl; }};// sub class derived from two base classesclass Car: public Vehicle, public FourWheeler {};// main functionint main(){ // creating object of sub class will // invoke the constructor of base classes Car obj;
}
Output:
This is a Vehicle This is a 4 wheeler Vehicle
|
Sunday, 1 July 2018
12th D Prog-7 Inheritance Programming;
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment