If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Threaded View

"new" type set at runtime?

I have several classes, which we'll call classA, classB and classC to keep things simple, all of which inherit from a single class, which we'll call baseClass. In my code I want to instantiate an object of one of the child types, based on what the user clicks on. So if they click "classA" I want to instantiate an object of type classA, etc. The way I have it working at the moment is that I have a pointer of type baseClass, and the user selection is stored in a string. The string is then run through an if statement which selects the appropriate new statement, something like the sudo-code below: