The first error is sourced here:
class Vehicle {
protected:
Vehicle myVehicle[9];
};
You can't use a class instance as a member of it's own class.
error:field 'myVehicle' has incomplete type vehicle [9]
note: definition of 'class vehicle' is not complete until closing brace
The class is not defined at that point so that the compiler does not know how to handle it.
The second error is sourced by the code block
Vehicle& getVehicle(int n) {
return myVehicle[n];
}
in your
valid_mileage()
function. It looks like it has been copied and pasted to the wrong location.
Note also that
::
is the scope resolution operator for name spaces and to access static members of a class. To access non static members of a class when the member name is also used as parameter, use the
this pointer - cppreference.com[
^]:
void Vehicle::setMake(string make) {
this->make = make;
}