Good day! I have a basic dialog-system and faced the problem of losing the pointer passed to the constructor.
I have a child class that calls the base constructor, passing the parameter further:
SceneTwo(shared_ptr<ContentManager>* manager) : GUIElement::GUIElement(manager) { } In the base class in the constructor, we initialize the required protected parameter for future access to it from the child classes.
GUIElement::GUIElement(shared_ptr<ContentManager>* manager) { _contentManagerPtr = manager; _sceneContainer = _contentManagerPtr->get()->sceneContainer(); } And that's what's interesting - when debugging, at the time of entry into
GUIElement::GUIElement(shared_ptr<ContentManager>* manager) manager - contains a pointer, but after 1 iteration, it throws me further by 3 steps in GUIElement.h, variables are inserted there and returned to the body of the constructor - the manager parameter is not correct ... http://prntscr.com/c082oc
shared_ptr- Pavel Parshinreturn &static_pointer_cast<ManagerType>And it turns out when static_pointer_cast creates a copy and is it destroyed? - Roman Lipovskiy