其他分享
首页 > 其他分享> > CFX_Object new delete

CFX_Object new delete

作者:互联网

// 你必须定义一个 `main()` 函数入口。
#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);
  }
  void* operator new(size_t size)
  {
    return malloc(size);
  }
  void operator delete(void* p)
  {
    free(p);
  }
    void*            operator new[] (size_t size, FX_LPCSTR file, int line)
    {
        return malloc(size);
    }
    void            operator delete[] (void* p, FX_LPCSTR file, int line)
    {
        free(p);
    }
    void*            operator new[] (size_t size)
    {
        return malloc(size);
    }
    void            operator delete[] (void* p)
    {
        free(p);
    }
    void*            operator new (size_t, void* buf)
    {
        return buf;
    }
    void            operator delete (void*, void*)                            {}
};
int main()
{
  cout << "Hello, World!" << endl;
  return 0;
}
 
  

 

标签:FX,void,Object,CFX,operator,new,delete,size
来源: https://www.cnblogs.com/hshy/p/15747329.html