Advertisement
Guest User

Untitled

a guest
Jan 21st, 2019
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3. using namespace std;
  4.  
  5. class Car{
  6.  
  7. string color;
  8. int price;
  9.  
  10. public:
  11.  
  12. Car(string c, int p){
  13. color=c;
  14. price=p;
  15. }
  16.  
  17. string getColor(){
  18. return color;
  19. }
  20.  
  21. void setColor(string color){
  22. Car::color=color;
  23. }
  24.  
  25. int getPrice(){
  26. return price;
  27. }
  28.  
  29. void setPrice(int price){
  30. Car::price=price;
  31. }
  32.  
  33. int increasePrice(int x){
  34. Price=Price+x;
  35. return Price;
  36. }
  37.  
  38. };
  39.  
  40. int main()
  41. {
  42. Car Object1("blue", 1000);
  43. Car Object2();
  44.  
  45. cout<<Object1.getColor();
  46. cout<<Object1.getPrice();
  47. cout<<Object2.getColor();
  48. cout<<Object2.getPrice();
  49.  
  50.  
  51.  
  52. return 0;
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement