operator new delete操作符重载

#include <iostream>
using namespace std;
typedef const char* FX_LPCSTR;
class CFX_Object
{
  public:
  void* operator new(size_t size, FX_LPCSTR file, int line)
  {
    return malloc(size);
  }
  
  void operator delete(void*p,FX_LPCSTR file,int size)
  {
    free(p);
  }
  
};
int main()
{
  cout << "Hello, World!" << endl;
  return 0;
}
 

  

posted on 2021-12-30 02:36  lydstory  阅读(33)  评论(0)    收藏  举报

导航