June 28th, 2013, 09:27 AM
Share-pointer and void
I have a share-pointer defined as
typedef std::share_ptr<MyClass> MyClassPtr;
and a class
Now that I would like to implement a polymophic behavior as
return new MyClass();
This is what I have shortened up, the project code is a lot and messy. For this simplified (not simple) case, it sure works but in my application, DoSomething in the child class is never called, but the base class' instead. However, if I could change MyClassPtr into void*, it would work for sure!
class BabyExample:public Example
return new MyClass_Baby();
I have tested this in those behaviors without share_ptr.
My questions are,
1. what actually happened that prevents the debugger from reaching the child method.
2. how can I change share-ptr to void*/void/void& ?
Click Here to Expand Forum to Full Width
This a Codeguru.com survey!