Advertisement
Potap

sdfsdf

Dec 14th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. #include <string>
  2. #include <sstream>
  3. #include <cstdlib>
  4. #include <iostream>
  5. #include <clocale>
  6.  
  7. using namespace std;
  8.  
  9. class matrix{
  10. public:
  11. int x;
  12. int y;
  13. matrix(int x, int y){
  14. this->x = x;
  15. this->y = y;
  16. }
  17. virtual int get_resolution(){
  18. return (x*y);
  19. }
  20. void print()
  21. {
  22. cout << x <<" "<< y <<" "<< get_resolution()<<endl;
  23. }
  24. virtual ~matrix() {}
  25. };
  26.  
  27. class processor{
  28. public:
  29. float chas;
  30. string arch;
  31. string name;
  32. processor(float chas, string arch, string name){
  33. this->chas = chas;
  34. this->arch = arch;
  35. this->name = name;
  36. }
  37. virtual void set(float chas2, string arch2, string name2){
  38. chas = chas2;
  39. arch = arch2;
  40. name = name2;
  41. }
  42. virtual string print()
  43. {
  44. cout<<"Частота: "<<chas<<"\n"
  45. <<"Архитектура: "<<arch<<"\n"
  46. <<"Имя: "<<name<<endl;
  47. return 0;
  48. }
  49. virtual ~processor() {}
  50. };
  51.  
  52. class phone: public processor, public matrix{
  53. public:
  54. float memory;
  55. float ves;
  56. string model_name;
  57. phone(float memory, float ves, string model_name, int x, int y, float chas, string arch, string name):processor(chas, arch, name),matrix(x,y){
  58. this->memory = memory;
  59. this->ves = ves;
  60. this->model_name = model_name;
  61. }
  62. virtual string print()
  63. {
  64. processor::print();
  65. matrix::print();
  66. cout<<"Память: "<<memory<<"\n"
  67. <<"Вес: "<<ves<<"\n"
  68. <<"Имя: "<<model_name<<endl;
  69. return 0;
  70. }
  71. virtual ~phone() {}
  72. };
  73.  
  74. int main(int argc, char* argv[])
  75. {
  76. setlocale (LC_ALL, "Russian");
  77. phone* mobile = new phone(2,4,"iphone",34,23,23,"ARH","Apple");
  78. mobile->print();
  79. return 0;
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement