topical media & game development
professional-program-13-ArrayDelete-ArrayDelete.c
? /
professional-program-13-ArrayDelete-ArrayDelete.c
include <iostream>
using namespace std;
class Simple
{
public:
Simple() { cout << "Simple constructor called!" << endl; }
};
int main(int argc, char** argv)
{
Simple** mySimplePtrArray = new Simple*[4];
// Allocate an object for each pointer.
for (int i = 0; i < 4; i++) {
mySimplePtrArray[i] = new Simple();
}
// Use mySimplePtrArray.
// Delete each allocated object.
for (int i = 0; i < 4; i++) {
delete mySimplePtrArray[i];
}
// Delete the array itself.
delete[] mySimplePtrArray;
}
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.