网上一个介绍VC内存调试的网页里面有这么一个介绍。问题是,我从来没有在MSDN上面看到过new可以带3个参数的啊。可以这样用么,能否举例?

解决方案 »

  1.   

    自动生成的代码文件都有
    #ifdef _DEBUG
    #define new DEBUG_NEW
    #endif在afx.h中
    #define DEBUG_NEW new(THIS_FILE, __LINE__)
    __FILE__
     The name of the current source file. __FILE__ expands to a string surrounded by double quotation s. To ensure that the full path to the file is displayed, use /FC (Full Path of Source Code File in Diagnostics).You can create your own wide string version of __FILE__ as follows:  Copy Code 
    #include <stdio.h>
    #define WIDEN2(x) L ## x
    #define WIDEN(x) WIDEN2(x)
    #define __WFILE__ WIDEN(__FILE__)
    wchar_t *pwsz = __WFILE__;int main() {}
     
    __FILE__
     The name of the current source file. __FILE__ expands to a string surrounded by double quotation s.
     
    __LINE__
     The line number in the current source file. The line number is a decimal integer constant. It can be altered with a #line directive. 
     
      

  2.   

    漏了一点,new被重载过的void* AFX_CDECL operator new(size_t nSize, LPCSTR lpszFileName, int nLine);