For example, in
unique_ptr<Derived> = new deriv;
std::vector<unique_ptr<Base>>.push_back(std::move(deriv));
will deriv be sliced to type unique_ptr<Base>?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No slicing will occur; the
unique_ptr<Base>will own the pointer to theDerivedobject.A
unique_ptrto a derived class can be implicitly converted to aunique_ptrto a base class.