huw@siesoft.co.uk (Huw Roberts) (09/11/90)
I have a file full of lines containing orders for a program to execute.
I want each line in the file to correspond to an instance of a class,
the exact class being determined by the content of the line.
So, for example, if the file contained:
order1(parameters)
order2(parameters)
order1(parameters)
I would want the program to create two instances of class "Order1" and
one instance of class "Order2".
Both Order1 and Order2 will be classes derived from a base class "Order".
Ideally, the information about which class is generated from each line would be
stored in a table somehow. But how do I do it? I don't want something like
switch(type)
{
case order1: object = new Order1();
break;
case order2: object = new Order2();
break;
}
and I would rather not have functions in a table, each of which generates
an instance of the class (this is what I would do in C) unless they were
member functions of the order classes.
Help
Thanks, Huw.
P.S. Please post me directly 'cos I don't normally read this group.