If my code is the following, how can I use delete to ensure all dynamically allocated data is deleted safely?
float** test;
test = new float*[3];
for(int i=0;i<3;i++)
test[i] = new float[2];
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.
The golden rule – for each
new/new[]you needdelete/delete[]. So:Same as with
new/new[], but in reversed order.