Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- using namespace std;
- class Car{
- string color;
- int price;
- public:
- Car(string c, int p){
- color=c;
- price=p;
- }
- string getColor(){
- return color;
- }
- void setColor(string color){
- Car::color=color;
- }
- int getPrice(){
- return price;
- }
- void setPrice(int price){
- Car::price=price;
- }
- int increasePrice(int x){
- Price=Price+x;
- return Price;
- }
- };
- int main()
- {
- Car Object1("blue", 1000);
- Car Object2();
- cout<<Object1.getColor();
- cout<<Object1.getPrice();
- cout<<Object2.getColor();
- cout<<Object2.getPrice();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement