Last active
March 29, 2019 11:24
-
-
Save kateolenya/fa02017e4c1da24384c02c45a911b127 to your computer and use it in GitHub Desktop.
Example of multiple inheritance in C++
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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