if (strcmp(Type,"Car")==0)
{
OCar.SetTyre(Tyre);
OCar.SetPaint(Paint);
OCar.SetDoor(Door);
OCar.SetMirror(Mirror);
OCar.SetGlass(Glass);
}
now if i want to use all these properties for a truck and other vehicles instead of me doing it like this over and over again
if (strcmp(Type,"Truck")==0)
{
OTruck.SetTyre(Tyre);
OTruck.SetPaint(Paint);
---------....
}
could i declare these properties only once somehow using functions or other things to simplify the program and make it smaller
if (strcmp(Type,"Car")==0)
{
one line of code (all the properties are called by this code)
}
if (strcmp(Type,"Truck")==0)
{
one line of code
}
THESE PROPERTIES ARE BEING READ FROM A FILE
AND THERE IS A CLASS CAR THAT IS INHERITING THESE PROPERTIES FROM OTHER CLASSES
AND OCar IS AN OBJECT
And could some one please give me a short example
thanks