#include <iostream>
usingnamespace std;
class Vehicle
{
private:
int Age; //The age of the vehicle
protected:
float Price; //The price of the vehicle
public:
Vehicle()
{
Age = 0;
Price = 0.0;
} //default constructor sets age=0, and price=0.0
~Vehicle()
{
Age = 0;
Price = 0.0;
} //destructor sets age=0, and price=0.0
void setAge(int x)
{
Age=x;
} //Takes an integer parameter, returns nothing
void setPrice(float x)
{
Price=x;
} //Takes a float parameter, returns nothing
int getAge()
{
return Age;
}// Takes no parameters, returns the vehicle’s age
float getPrice()
{
return Price;
} // Takes no parameters, returns the vehicle’s price
};
class Car: public Vehicle
{
private:
bool RaceCarStatus;
public:
Car()
{
RaceCarStatus = false;
}
~Car()
{
RaceCarStatus = false;
}
void setRaceCarStatus(bool y)
{
RaceCarStatus=y;
};
bool getRaceCarStatus()
{
return RaceCarStatus;
}
};
int main()
{
Vehicle x;
cout << "Initial value for x: " << endl;
cout << "Age = " << x.getAge() << " Price= " << x.getPrice() << endl;
x.setAge(40);
x.setPrice(20000);
cout << "Modified value for x: " << endl;
cout << "Age = " << x.getAge() << " Price= " << x.getPrice() << endl;
Car y;
cout << "Initial value for x: " << endl;
cout << "Age = " << x.getAge() << " Price= " << x.getPrice() << "Race Car Status="<< y.getAge()<< endl;
x.setAge(40);
x.setPrice(20000);
y.setRaceCarStatus(true);
cout << "Modified value for x: " << endl;
cout << "Age = " << x.getAge() << " Price= " << x.getPrice() << "Race Car Status="<< y.getAge() <<endl;
return 0;
}
You don't need semi-colons at the ending brace of a function but you do need one at the ending brace of a class. You also has some weird bracketing syntax:
bool getRaceCarStatus(){return{RaceCarStatus;};
should be:
bool getRaceCarStatus(){return RaceCarStatus;}
Syntax errors are really all that was wrong with your code.