我有模板类“工厂”。工厂的原型如下:
template <class T>
class Factory
{
public:
Factory();
~Factory();
//few more functions & data-members
private:
//few more functions & data-members
};
在 main() 中,我制作了多种类型的工厂,如下所示 -
int main()
{
typedef Factory<int> IntFactory ;
IntFactory A = IntFactory();
typedef Factory<float> FloatFactory ;
FloatFactory B = FloatFactory();
//Complex is some user defined class
typedef Factory<Complex> ComplexFactory ;
ComplexFactory C = ComplexFactory();
//Point3D is a user defined class
typedef Factory<Point3D> Point3DFactory ;
Point3DFactory D = Point3DFactory();
//I may have several such initializations.
}
问题是如何创建对象数组 A、B、C、D 以防我想遍历它们?