// operator delete[] example
#include < iostream >
#include < new >
using namespace std;
struct myclass {
myclass() {cout <<"myclass constructed\n";}
~myclass() {cout <<"myclass destroyed\n";}
};
int main () {
myclass * pt;
pt = new myclass[3];
delete[] pt;
return 0;
}
Output:
myclass constructed
myclass constructed
myclass constructed
myclass destroyed
myclass destroyed
myclass destroyed
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment