- Produce was not declared virtual
-
class BuildingT {
public:
BuildingT(WarehouseT w, BuildingTypeT t);
...
void Produce(WarehouseT w);
- And so
genericBuilding = make_unique<FarmT>(warehouse);
genericBuilding->CanProduce(warehouse);
genericBuilding->Produce(warehouse);
- produced
-
In the FarmT class, building a farm
Base class checking to see if we can produce
Base class producing
- In the new example Produce is declared virtual
-
class BuildingT {
public:
BuildingT(WarehouseT w, BuildingTypeT t);
...
virtual void Produce(WarehouseT w);
- So the code produces
-
In the FarmT class, building a farm
Base class checking to see if we can produce
A Farm is producing