Skip to content

Instantly share code, notes, and snippets.

@kateolenya
Last active March 29, 2019 11:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kateolenya/fa02017e4c1da24384c02c45a911b127 to your computer and use it in GitHub Desktop.
Save kateolenya/fa02017e4c1da24384c02c45a911b127 to your computer and use it in GitHub Desktop.
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