Advertisement
WupEly

Untitled

Oct 5th, 2022
577
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. class Car {
  6. public:
  7.     string name;
  8.     string engine;
  9.     string gearbox;
  10.     int wheels;
  11.     int year;
  12.     bool working = false;
  13.  
  14.     Car(string n, string e, string gb, int wh, int y) {
  15.         name = n;
  16.         engine = e;
  17.         gearbox = gb;
  18.         wheels = wh;
  19.         year = y;
  20.     }
  21.  
  22.     ~Car(){};
  23.  
  24.     void start_engine() {
  25.         working = true;
  26.     }
  27.  
  28.     void stop_engine() {
  29.         working = false;
  30.     }
  31. };
  32.  
  33. int main()
  34. {
  35.     Car renault("Renault Logan", "1.4", "Auto", 4, 2015);
  36.     Car volvo("volvo s60", "2.0", "Robot", 4, 2004);
  37.  
  38.     renault.start_engine();
  39.  
  40.     cout << renault.working << endl;
  41.     cout << volvo.working;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement