//7A C++ program to explain // Multiple inheritance #include <iostream.h> // first base class class Vehicle { public : Vehicle() { cout << "This is a Vehicle" << endl; } }; // second base class class FourWheeler { public : FourWheeler() { cout << "This is a 4 wheeler Vehicle" << endl; } }; // sub class derived from two base classes class Car: public Vehicle, public FourWheeler { }; // main function int 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