Computer Science, asked by charanpatchipala, 5 months ago

Create three class names VEHICLE, TWO WHEELER, SCOOTER as shown

below and create the data members and member function. Create a base class

“vehicle” and declare the variable reg_no as string and model as integer. Create a

function read()inside the class to read data for the variables. Create a derived​

Answers

Answered by sarwattahir512
0

Explanation:

irst error is sourced here:

Hide Copy Code

class Vehicle {

protected:

Vehicle myVehicle[9];

// ...

};

You can't use a class instance as a member of it's own class.

Hide Copy Code

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

Hide Copy Code

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[^]:

Hide Copy Code

void Vehicle::setMake(string make) {

this->make = make;

}

Similar questions