Program to understand the concept of new and delete operator. in cpp

/*Program to understand the concept of new and delete operator.*/


#include <iostream>
using namespace std;
class opp
{
  public:
  opp()
  {
    cout<<"new called";
  }
  ~opp()
  {
    cout<<"\ndelete called";
  }
};
int main()
{
   opp *obj=new opp();
   delete (obj);
   return 0;
}

Output:


Related Posts:

0 comments: