Advertisement
Guest User

Untitled

a guest
Mar 26th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class Device {
  5. public:
  6. // constructor
  7. Device() {
  8. cout << "Device constructor called" << endl;
  9. }
  10. // destructor
  11. ~Device() {
  12. cout << "Device destructor called" << endl;
  13. }
  14. };
  15.  
  16. class Computer: public Device {
  17. public:
  18. Computer() {
  19. cout << "Computer constructor called" << endl;
  20. }
  21. ~Computer() {
  22. cout << "Computer destructor called" << endl;
  23. }
  24. };
  25.  
  26. class Laptop: public Computer {
  27. public:
  28. Laptop() {
  29. cout << "Laptop constructor called" << endl;
  30. }
  31. ~Laptop() {
  32. cout << "Laptop destructor called" << endl;
  33. }
  34. };
  35.  
  36. int main() {
  37. cout << "\tConstructors" << endl;
  38. Laptop my_laptop;
  39. cout << "\tDestructors" << endl;
  40.  
  41. return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement