AFAIK, reduce the number of sub classing means you don't actually code the class statically but you create the object with different properties in order to avoid create many subclass.
class carPrototype : public prototype
{
prototype* clone();
};
Yon doesn't require to create a class called sedanCarPrototype, superCarPrototype but just clone from carPrototype and used a ID to identified its type. This differentiate by the capacity of the car. For instance, 1600 cc type B class segment is sedanCarPrototype and 3000 cc type D class segment is a superCarPrototype.
Is this correct as reduce number of subclassing ?
You need Prototype pattern. Every class derived from base Prototype class should have method clone() const; (with NO arguments) which will return copy of current class.
Make a map, fill it with empty objects corresponding for each id. If object found in map, call clone, return new copy, and call virtual load() method. This way you'll get "dynamic loading".
How does the load() implements ?
Please help.
Thanks.