Advertisement
Guest User

Untitled

a guest
Oct 27th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. #include<string>
  2. #include<iostream>
  3. using namespace std;
  4.  
  5. class Car
  6. {
  7. string make, model;
  8. int year;
  9. double price;
  10. //The lines above, since they are not declared to be public or private, are declared private by default
  11. public:
  12. Car();
  13. void print();
  14. bool operator == (Car car);
  15. friend void set_data(Car &c);
  16. };
  17.  
  18. Car::Car()
  19. {
  20. this->make = "";
  21. this->model = "";
  22. this->price = 0.0;
  23. this->year = 0;
  24. }
  25.  
  26. void Car::print()
  27. {
  28. cout << "Make: " << this->make << endl;
  29. cout << "Model: " << this->model << endl;
  30. cout << "Price: " << this->price << endl;
  31. cout << "Year: " << this->year << endl;
  32.  
  33. return;
  34. }
  35.  
  36. bool Car::operator == (Car car)
  37. {
  38. return this->make == car.make;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement