Created
March 28, 2019 12:55
-
-
Save kateolenya/cfa7dbcd9d16ca0bbff95e53d0a3dfcc to your computer and use it in GitHub Desktop.
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 Device { | |
public: | |
void turn_on() { | |
cout << "Device is on." << endl; | |
} | |
virtual void say_hello() = 0; | |
}; | |
class Laptop: public Device { | |
public: | |
void say_hello() { | |
cout << "Hello world!" << endl; | |
} | |
}; | |
int main() { | |
Laptop Laptop_instance; | |
Laptop_instance.turn_on(); | |
Laptop_instance.say_hello(); | |
// Device Device_instance; | |
// will cause compile time error | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment