Path: utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!samsung!uunet!mcsun!ukc!stl!siesoft!huw From: huw@siesoft.co.uk (Huw Roberts) Newsgroups: comp.lang.c++ Subject: Virtual creation of class instances? (help) Summary: I want to create instances of an unknown class at run time. Keywords: parse virtual creation Message-ID: <1990Sep10.182039.8327@siesoft.co.uk> Date: 10 Sep 90 18:20:39 GMT Sender: usenet@siesoft.co.uk (NNTP Poster) Distribution: comp Organization: Siemens System Developement Group, Reading, UK Lines: 30 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.