| So at this point I'd imagine the pointer structure be something like: pSourceObject (points to)-> m_object[i] (points to)-> data |
delete, you are not deleting the pointer, you are deleting whatever the pointer points to. In this case, since pSourceObject points to 'foo', if you were to delete pSourceObject; you would be deleting foo, after which, pSourceObject would point to unallocated/bad memory.| My question is, wouldn't calling DELETE here delete the stored data? |
delete pSourceObject; then foo is destroyed which means all its associated data disappears.
| If you delete pSourceObject; then foo is destroyed which means all its associated data disappears. |
| based on this statement i'd assume the pointers after the DELETE would be: pSourceObject (points to)-> NOTHING foo (points to)-> NOTHING data in memory(in my case an object) = Garbage/Free TBH, this doesnt make much sense. I would instead expect this to happen: pSourceObject (points to)-> NOTHING foo (points to)-> data in memory(in my case an object) |
| BlatantlyX wrote: |
|---|
| Have a look at the class destructor, because the destructor is called when you use delete. |
| forgot to put in that foo is a pointer to some place in memory. |
new keyword -- you create all those variables. You create (or "allocate") that block of memory. You create that object. |
|