A quick question...
How do you delete a dynamically created array composed of base class pointers, where each pointer is pointing to objects of the base class and various derived classes?
Thanks in advance![]()
This is a discussion on Need some help with Delete within the C++ Programming forums, part of the General Programming Boards category; A quick question... How do you delete a dynamically created array composed of base class pointers, where each pointer is ...
A quick question...
How do you delete a dynamically created array composed of base class pointers, where each pointer is pointing to objects of the base class and various derived classes?
Thanks in advance![]()
As long as you have already deleted the pointed to objects or you have another copy of the pointers then all you need do is....
delete[] pointer_to_dynamic_array;
Free the weed!! Class B to class C is not good enough!!
And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi
afterthought....
If you want to know how to delete the objects pointed to first then as long as your base class has a virtual destructor then you can call delete on the base class pointers knowing that the derived class destructor will be called.
Free the weed!! Class B to class C is not good enough!!
And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi