Sunday, January 01, 2006

De-allocation using delete

----------------------------Code 1 ----------------------------------------------------------

 

#include <memory>

#include <iostream.h>

 

using namespace std;

int main()

{

     std::auto_ptr<int> * i = new std::auto_ptr<int>[2];

     int j = 0;

     i[0].reset( new int(j) );

     i[1].reset( new int(j) );

     delete []i;

     return 0;

}

 

------------------------------------------EOF------------------------------------------------

 

Pradyut
http://pradyut.tk
http://spaces.msn.com/members/oop-edge/
http://groups-beta.google.com/group/oop_programming
India

 

No comments: