I am programming in C ++ and I have 3 classes that inherit from each other:
Hatchback -> Car -> Vehicle;
I want to print attributes from each class using a method void print(),
Each class has a printing method that prints its own attributes.
void Vehicle::print()
{
}
void Car::print()
{
}
void Hatchback::print()
{
}
I create an object that initializes ALL attributes from ALL classes in one constructor:
Hatchback hatchback("L880UCD", "Vauhall", "Corsa",
"White", "None", "Car", "Hatchback",
3, 5, "Manual", 3, 2, 1);
The problem is that I want to print all the attributes using one printing method, so when I call,
object.print();
it goes through the vehicle printing method, then the car printing method, then the Hatchback printing method. A.
, , . , ... , !
, , , , Vehicle, Container, Tanker, Flatbed, Motorbike, Transit ETC ETC, , .
Print Vehicle !
, .
, , , , .
! , Noob... !:)