Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


#ActualLordRhys

Posted 26 April 2013 - 09:12 AM

Another example:
int* ptr1=NULL, ptr2=NULL, ptr3=NULL, ptr4=NULL;
ptr1=new int;
ptr2=ptr1;
ptr3=ptr2;
ptr4=ptr3;
delete ptr4;


Am I freeing ptr1-3, when freeing ptr4?



From what I read in C++ Primer Plus this wouldn't work since ptr2,ptr3, and ptr4 are not considered pointers but ordinary int variables, the statement would have to be:
int* ptr1 = NULL, *ptr2 = NULL, *ptr3 = Null, etc...

#1LordRhys

Posted 26 April 2013 - 09:10 AM

Another example: int* ptr1=NULL, ptr2=NULL, ptr3=NULL, ptr4=NULL; ptr1=new int; ptr2=ptr1; ptr3=ptr2; ptr4=ptr3; delete ptr4; Am I freeing ptr1-3, when freeing ptr4? From what I read in C++ Primer Plus this wouldn't work since ptr2,ptr3, and ptr4 are not considered pointers but ordinary int variables, the statement would have to be: int* ptr1 = NULL, *ptr2 = NULL, *ptr3 = Null, etc...

PARTNERS