Note : passing atuo_ptrs are problematic because of the ownershipCode:auto_ptr<B> ptr(new D);
of the pointer when copied.
After calling the function, do the following:
Also, add a destructor to the classes, printing out a message, and seeCode:bar(ptr); if (ptr.get() == NULL) { cout << "null\n"; }
when the pointer gets deleted.




Reply With Quote