I know free() won’t call the destructor, but what else will this cause besides that the member variable won’t be destructed properly?
Also, what if we delete a pointer that is allocated by malloc?
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.
It is implementation defined whether
newusesmallocunder the hood. Mixingnewwithfreeandmallocwithdeletecould cause a catastrophic failure at runtime if the code was ported to a new machine, a new compiler, or even a new version of the same compiler.