Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Example of multiple inheritance in C++
#include <iostream>
using namespace std;
class Computer {
public:
void turn_on() {
cout << "Welcome to Windows 95" << endl;
}
};
class Monitor {
public:
void show_image() {
cout << "Imagine image here" << endl;
}
};
class Laptop: public Computer, public Monitor {};
int main() {
Laptop Laptop_instance;
Laptop_instance.turn_on();
Laptop_instance.show_image();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.