#include <iostream>
usingnamespace std;
class Car{
public:
void setMake(string a) {make = a;}
void setModel(string o) {model = o;}
void setYear(unsigned y) {year = y;}
void setPrice(unsigned p) {price = p;}
string getMake() const {return make;}
string getModel() const {return model;}
unsigned getYear() const {return year;}
unsigned getPrice() const {return price;}
void compare(const Car& b) const {
if(price > b.price) cout << model "is a better deal" << endl; // This line has an error.
else
cout << b.model "is a better deal" << endl; // This line has an error.
}
private:
string make;
string model;
unsigned year;
unsigned price;
};
int main(){
Car c;
Car d;
c.setMake("Ford");
c.setModel("Escort");
c.setYear(1995);
c.setPrice(6000);
d.setMake("Chevy");
d.setModel("S-10");
d.setYear(1993);
d.setPrice(3000);
cout << c.getMake() << endl;
cout << c.getModel() << endl;
cout << c.getYear() << endl;
cout << c.getPrice() << endl;
c.compare(d);
}
Here are the errors
1 2 3 4
31.cpp: In member function `void Car::compare(const Car&) const':
31.cpp:15: error: expected `;' before string constant
31.cpp:17: error: expected `;' before string constant