Hello
I'll describe my problem. I've got a vehicle class (cVehicle), and two 'heirs', car (cCar)and van (cVan). The vehicle class has atributes X and Y, car has C and van has V, and both heirs inherit X and Y.
i have a class called Vehiclefactory which has a method which recieves a string with the atributes and it must return a Cvehicle object. Then i must add it to a list.
Inside Vehiclefactory.create function, if i get a string with a C, i must create a car, and if i get a string with a V i must create a vanCode:
CVehiculo* temp = Vehiclefactory.Create (" string with atributes");
VehicleList.Add (temp);
but the function returns a cVehicle class, so i lost the car or van atribute.Code:if (c==C)
{
cCar * car = new cCcar(X,Y,C);
return aut;
}
if (c==V)
{
cVan * van = new cVan(X,Y,V);
return van;
}
i really need the create function to return a Cvehicle class, but i need to actualle return a car or a van, to be able to see its atributes and then to add it to a list. these lines of code must be in the programCode:
class cVehiclefactory
{
private:
FILE *data;
public:
void read (char * filename);
cvehiculo * Create (char data[51]);
};
hope you can help me!!Code:
CVehiculo* temp = Vehiclefactory.Create (" string with atributes");
VehicleList.Add (temp);
thanks
