Advertisement
Guest User

Untitled

a guest
Jan 17th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. class tel
  6. {
  7. protected:
  8. int diag;
  9. string casti;
  10.  
  11. public:
  12. tel(int, string);
  13. ~tel();
  14. tel();
  15. void afisare();
  16. int set_diag(int a);
  17. };
  18. tel::tel()
  19. {
  20. diag=0;
  21. casti=" ";
  22. }
  23. tel::~tel()
  24. {
  25. cout<<"Distruge obiect"<<endl<<endl;
  26. }
  27. tel::tel(int a, string b)
  28. {
  29. diag=a;
  30. casti=b;
  31. }
  32. void tel::afisare()
  33. {
  34. cout<<diag<<endl<<casti<<endl<<endl;
  35. }
  36.  
  37. int tel::set_diag( int a)
  38. {
  39. diag=a;
  40. }
  41.  
  42.  
  43.  
  44. class pc
  45. {
  46. protected:
  47. int ram;
  48. string procesor;
  49.  
  50. public:
  51. pc(int, string);
  52. ~pc();
  53. pc();
  54. void afisare();
  55. void get_ram();
  56. };
  57.  
  58. pc::pc()
  59. {
  60. ram=0;
  61. procesor=" ";
  62. }
  63.  
  64. pc::~pc()
  65. {
  66. cout<<"Obiectul a fost distrus"<<endl<<endl;
  67. }
  68.  
  69. pc::pc( int a, string b)
  70. {
  71. ram=a;
  72. procesor=b;
  73. }
  74.  
  75. void pc::afisare()
  76. {
  77. cout<<ram<<endl<<procesor<<endl<<endl;
  78. }
  79.  
  80. void pc::get_ram()
  81. {
  82. cout<<ram<<endl<<endl;
  83. }
  84.  
  85.  
  86. class SmartTEL: public tel, public pc
  87. {
  88. private:
  89. string so;
  90. int camera;
  91.  
  92. public:
  93. SmartTEL( int, string, int, string, string, int);
  94. ~SmartTEL();
  95. void afisare();
  96. void set_casti( string b);
  97. friend istream& operator>>(istream&, SmartTEL&);
  98. };
  99.  
  100. SmartTEL::SmartTEL( int a, string b, int c, string d, string e, int f): tel(a, b), pc(c, d)
  101. {
  102. so=e;
  103. camera=f;
  104. cout<<"Constructor SmartTEL"<<endl<<endl;
  105. }
  106.  
  107. SmartTEL::~SmartTEL()
  108. {
  109. cout<<"S-a distrus obiectul"<<endl<<endl;
  110. }
  111.  
  112. void SmartTEL::afisare()
  113. {
  114. tel::afisare();
  115. pc::afisare();
  116. cout<<so<<endl<<camera<<endl<<endl;
  117. }
  118.  
  119. void SmartTEL::set_casti( string t)
  120. {
  121. casti=t;
  122. }
  123.  
  124. istream& operator>>(istream&in, SmartTEL&s)
  125. {
  126. in>>s.diag>>s.casti>>s.ram>>s.procesor>>s.so>>s.camera;
  127. return in;
  128. }
  129.  
  130. int main()
  131. {
  132. tel t1(3, "da");
  133. pc p1( 4, "Dual 1.2");
  134. SmartTEL s1(5, "da", 2, "Octa 1.2", "Android 6.0", 16);
  135. t1.afisare();
  136. p1.afisare();
  137. s1.afisare();
  138. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement