lundi 3 juillet 2017

How to create an object in a situation where the type is only known at runtime?

I have two product classes, Line and Trunk which both require getServiceFee and setServiceFee functions that return/manipulate their serviceFee member variable.

  1. how do I create a Line or Trunk in a situation where the type of object is only known at runtime
  2. how do i write a function which is passed the object to be updated assuming I do not know whether the object passed to it is a Line or a Trunk.

Aucun commentaire:

Enregistrer un commentaire