It's near the bottom, in line 143. The logic should be the following:
If (Input[0] == 1){
AllCars.FuelType = "Petrol"
}
else if (Input[0] == 2){
AllCars.FuelType = "Diesel"
}
however, it won't let me do that.
Before anyone says anything about the way I am doing this, I do not want to change it, I only want to know that one thing... how to make that ^^ above work and yes, I am aware I use system("PAUSE") and system("clr").
Thanks for the reply - I don't know why I didn't see that in the first place, however, I'm still getting an error from line 143. The error i'm getting reads:
char AllCars::FuelType[6]
Error: a nonstatic member reference must be relative to a specific object
It seems to me that Vans, SportsCars and FourByFour should inherit from AllCars but they don't, is this correct?
If so...
Class declarations should look like...
Class SportsCars : public AllCars...
Your error on line 143 is occuring because AllCars is a class not an instance of a class. You must first instantiate an AllCars object before modifying said value.
You still haven't declared your child classes as actual children of AllCars:
1 2 3 4 5 6
class SportsCars}class SportsCars: public AllCars {
public:
bool SoftTop;
bool Alloys;
};
Also, to clarify Georgewashere's point, if you want to call a method or property of an AlCars object, you need to do to as such:
1 2
AllCars AllCarObject;
AllCarObject.method();
A class is a blueprint (like that of a house), the actual house is called an object, and only in an object (actual house as opposed to the mere plan)you can actually do stuff like house.turnOnHeating(); .