I mean, if i have some class like:
class A{
int* pi;
};
*A pa;
when i call delete pa, will pi be deleted?
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.
You need to define a destructor to
delete pi;. In addition you also need to define a copy constructor and assignment operator otherwise when an instance ofAis copied two objects will be pointing to the sameint, which will be deleted when one of the instances ofAis destructed leaving the other instance ofAwith a dangling pointer.For example: