fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. class passenger{
  4. private:
  5. int m;
  6. string to, from, type_p;
  7. bool inBus=false, h, isNecB=true, paid=false;
  8. public:
  9. passenger(int money, string _from, string _to, bool health)
  10. {
  11. m=money;
  12. //type_p=p;
  13. from=_from;
  14. to=_to;
  15. h=health;
  16.  
  17. }
  18. int M()
  19. {
  20. return m;
  21. }
  22. bool H()
  23. {
  24. return h;
  25. }
  26. void InBus()
  27. {
  28. inBus=1;
  29. }
  30. bool state()
  31. {
  32. return inBus;
  33. }
  34. void pay()
  35. {
  36. m-=1400;
  37. paid=1;
  38. }
  39. bool chpay()
  40. {
  41. return paid;
  42. }
  43. bool isNec()
  44. {
  45. return isNecB;
  46. }
  47. void leftBus()
  48. {
  49. isNecB=0;
  50. inBus=0;
  51. }
  52. string From()
  53. {
  54. return from;
  55. }
  56. string To()
  57. {
  58. return to;
  59. }
  60.  
  61. };
  62. class conductor{
  63. private:
  64. bool h;
  65. int m;
  66. public:
  67. conductor(bool health, int money)
  68. {
  69. h=health;
  70. m=money;
  71. }
  72. bool H()
  73. {
  74. return h;
  75. }
  76. void MforT()
  77. {
  78. m+=1400;
  79. }
  80.  
  81. };
  82. class driver{
  83. private:
  84. bool h, s;
  85. public:
  86. driver(bool health, bool safety)
  87. {
  88. h=health;
  89. s=safety;
  90. }
  91. bool H()
  92. {
  93. return h;
  94. }
  95. bool S()
  96. {
  97. return s;
  98. }
  99.  
  100. };
  101. class Route{
  102. private:
  103. passenger student;
  104. conductor c;
  105. driver d;
  106. string BusStop[7]={"Beltepa","ToshMI","Karima","Beruniy","Huvaydo","Tinchlik","Chorsu"};
  107. public:
  108. void input()
  109. {
  110.  
  111. int money;
  112. string from, to;
  113. bool health, safety;
  114. cout<<"Input student's money, from, to, health:\n";
  115. cin>>money>>from>>to>>health;
  116. student(money,from,to,health);
  117. cout<<"Input conductor's health, money:\n";
  118. cin>>money>>health;
  119. c(health,money);
  120. cout<<"Input driver's health, safety\n";
  121. cin>>health>>safety;
  122. d(health,safety);
  123. }
  124. void route()
  125. {
  126. if(!(c.H()&&d.H()))cout<<"Service doesn't satisfy for route\n";
  127. else{
  128. cout<<"Driver and conductor are healthy and bus is safe\n";
  129. for(int i=0; i<BusStop.size(); i++)
  130. {
  131. cout<<"Bus stop #"<<i+1<<": "<<BusStop[i]<<endl;
  132. if(BusStop[i]==student.From())
  133. {
  134. cout<<"A student has got on the bus\n";
  135. student.inBus();
  136. if(student.H())
  137. {
  138. cout<<"The student is healthy\n";
  139. if(student.M()>=1400)
  140. {
  141. cout<<"The student has got enough money. He can use public transport\n";
  142. student.pay();
  143. c.MforT();
  144. }
  145. else {
  146. cout<<"The student has got neither a travel card nor money. He has to leave bus immediately\n";
  147. student.leftBus();
  148. }
  149. }
  150. }
  151. else if(student.inBus()&&BusStop[i]==student.To())
  152. {
  153. cout<<"The student arrived to destination\n";
  154. student.leftBus();
  155. }
  156. }
  157. }
  158. }
  159. };
  160. int main()
  161. {
  162.  
  163. Route obj;
  164. obj.input();
  165. obj.route();
  166. }
  167.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In member function ‘void Route::input()’:
prog.cpp:116:37: error: no match for call to ‘(passenger) (int&, std::__cxx11::string&, std::__cxx11::string&, bool&)’
         student(money,from,to,health);
                                     ^
prog.cpp:119:23: error: no match for call to ‘(conductor) (bool&, int&)’
         c(health,money);
                       ^
prog.cpp:122:24: error: no match for call to ‘(driver) (bool&, bool&)’
         d(health,safety);
                        ^
prog.cpp: In member function ‘void Route::route()’:
prog.cpp:129:36: error: request for member ‘size’ in ‘((Route*)this)->Route::BusStop’, which is of non-class type ‘std::__cxx11::string [7]’ {aka ‘std::__cxx11::basic_string<char> [7]’}
             for(int i=0; i<BusStop.size(); i++)
                                    ^~~~
prog.cpp:135:29: error: ‘bool passenger::inBus’ is private within this context
                     student.inBus();
                             ^~~~~
prog.cpp:7:16: note: declared private here
     bool inBus=false, h, isNecB=true, paid=false;
                ^~~~~
prog.cpp:135:29: note: field ‘bool passenger::inBus’ can be accessed via ‘bool passenger::state()’
                     student.inBus();
                             ^~~~~
                             state()
prog.cpp:135:35: error: expression cannot be used as a function
                     student.inBus();
                                   ^
prog.cpp:151:33: error: ‘bool passenger::inBus’ is private within this context
                 else if(student.inBus()&&BusStop[i]==student.To())
                                 ^~~~~
prog.cpp:7:16: note: declared private here
     bool inBus=false, h, isNecB=true, paid=false;
                ^~~~~
prog.cpp:151:33: note: field ‘bool passenger::inBus’ can be accessed via ‘bool passenger::state()’
                 else if(student.inBus()&&BusStop[i]==student.To())
                                 ^~~~~
                                 state()
prog.cpp:151:39: error: expression cannot be used as a function
                 else if(student.inBus()&&BusStop[i]==student.To())
                                       ^
prog.cpp: In function ‘int main()’:
prog.cpp:163:11: error: use of deleted function ‘Route::Route()’
     Route obj;
           ^~~
prog.cpp:101:7: note: ‘Route::Route()’ is implicitly deleted because the default definition would be ill-formed:
 class Route{
       ^~~~~
prog.cpp:101:7: error: no matching function for call to ‘passenger::passenger()’
prog.cpp:9:5: note: candidate: ‘passenger::passenger(int, std::__cxx11::string, std::__cxx11::string, bool)’
     passenger(int money, string _from, string _to, bool health)
     ^~~~~~~~~
prog.cpp:9:5: note:   candidate expects 4 arguments, 0 provided
prog.cpp:3:7: note: candidate: ‘passenger::passenger(const passenger&)’
 class passenger{
       ^~~~~~~~~
prog.cpp:3:7: note:   candidate expects 1 argument, 0 provided
prog.cpp:3:7: note: candidate: ‘passenger::passenger(passenger&&)’
prog.cpp:3:7: note:   candidate expects 1 argument, 0 provided
prog.cpp:101:7: error: no matching function for call to ‘conductor::conductor()’
 class Route{
       ^~~~~
prog.cpp:67:5: note: candidate: ‘conductor::conductor(bool, int)’
     conductor(bool health, int money)
     ^~~~~~~~~
prog.cpp:67:5: note:   candidate expects 2 arguments, 0 provided
prog.cpp:62:7: note: candidate: ‘constexpr conductor::conductor(const conductor&)’
 class conductor{
       ^~~~~~~~~
prog.cpp:62:7: note:   candidate expects 1 argument, 0 provided
prog.cpp:62:7: note: candidate: ‘constexpr conductor::conductor(conductor&&)’
prog.cpp:62:7: note:   candidate expects 1 argument, 0 provided
prog.cpp:101:7: error: no matching function for call to ‘driver::driver()’
 class Route{
       ^~~~~
prog.cpp:86:5: note: candidate: ‘driver::driver(bool, bool)’
     driver(bool health, bool safety)
     ^~~~~~
prog.cpp:86:5: note:   candidate expects 2 arguments, 0 provided
prog.cpp:82:7: note: candidate: ‘constexpr driver::driver(const driver&)’
 class driver{
       ^~~~~~
prog.cpp:82:7: note:   candidate expects 1 argument, 0 provided
prog.cpp:82:7: note: candidate: ‘constexpr driver::driver(driver&&)’
prog.cpp:82:7: note:   candidate expects 1 argument, 0 provided
stdout
Standard output is empty