How to initialize object dynamically in the program without inheritance in c++? For example i Have class A and class B. And depend on condition i need to create instance of object but i don't know exactly what object i need to create, it depends on information that user input;
Example code:
int i;
cin>>i>>endl;
void *obj;
if(i)
obj = new A();
else
obj = new B();