I have a simple program where I am trying to do operator overloading for new and delete. 

Just for trying, I did operator overloading for new and delete in global scope apart from class scope.

```
#include<iostream>
#include<stdio.h>
 #include<stdlib.h>
using namespace std;

void * operator new(size_t size)
{
    cout<<"\n\nGlobal scope new:\n";
   void * ptr = malloc(size);
   return ptr;
}

void operator delete(void *ptr)
{
    cout<<"\n\nGlobal scope delete:\n";
    free(ptr);

}

  class test
  {

      public:
     int age;
     string name;

test(string str, int a)
{
    age = a;
    name = str;
}
 void display();   
 };

 void test::display()
 {
    cout<<"\n\nname is:-"<<name<<"  and age is :- "<<age<<endl;
 }

int main()
  {

  test *t = new test("sanjeev",29);
  if(t!=NULL)
  cout<<"\n\nMemory allocated:"<<endl;
  t->display();
   delete t;
 }

```

Now on executing this program I am seeing that new is called 3 times and delete is called 3 times.

![](https://i.stack.imgur.com/m7RYk.jpg)

If I declare new and delete operator overloading inside class only one time call to new and delete is happening.

What is the reason behind this flow?