I thought that the delete command would free up memory I allocated. Can someone explain why it seems I still have the memory in use after delete?
class Test
{
pu
Pointers are a container for an address in memory. You can always use a declared pointer, but unless it's initialized to memory that you own, expect confusion and worse.
Test *e;
e->time = 2;
also compiles and won't work. Minimize this type of confusion so:
{
boost::scoped_ptr e(new Test);
e->time = 1;
cout << e->time << endl;
e->time = 2;
cout << e->time << endl;
}
No new/delete
needed, just enclosing braces to define the scope, and an appropriate smart pointer.