Microsoft Visual Studio Projects DISCUSSION

Newing a derived class to create a default object

Started by syedzainnasir Newing a derived class to create a default object
0 replies 248 views 1 participants
Latest activity · 07 Mar 2017

Newing a derived class to create a default object

syedzainnasir Microsoft Visual Studio Projects Forum
#1
I have a base class which has several derived classes. Within the derived class I have an enum which tells me which derived class the object belongs to. Now, I want a function create a new object of a derived class, and the only parameter I'd pass would be the enum value of the class I want to create.

I can easily make a function which does a case/switch on the enum and does the appropriate new, but I was wondering if there is a better/more elegant/different way of doing it...?

Community replies 0

Be the first to help

There are no replies yet.

TEP COMMUNITY