Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class Device {
- public:
- int serial_number = 12345678;
- void turn_on() {
- cout << "Device is on" << endl;
- }
- };
- class Computer: private Device {
- public:
- void say_hello() {
- turn_on();
- cout << "Welcome to Windows 95!" << endl;
- }
- };
- int main() {
- Device Unknown_device;
- Computer my_computer;
- cout << "\t Unknown Device" << endl;
- cout << "Serial number is: "<< Unknown_device.serial_number << endl;
- Unknown_device.turn_on();
- // cout << "Serial number is: " << my_computer.serial_number << endl;
- // my_computer.turn_on();
- // will cause compile time error
- cout << "\t My computer" << endl;
- my_computer.say_hello();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement