C/C++教程

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;
}
 
  

 

这篇关于CFX_Object new delete的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!