1 CTestDlg *x;
2 x=new CTestDlg(this);
3 Graphics *y;
4 y=new Graphics(m_hWnd);是不是几乎一模一样的东西,VC6.0却说:error C2660: 'new' : function does not take 3 parameters  指的是第 4 行!为啥第2行没问题第四行却出毛了呢??我知道去掉
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
就没事了  可是我想知道为什么   2跟4一样的东西不可能有代码歧视吧。

解决方案 »

  1.   

    补充一下,.NET C#用的GDI+库和头文件和VC++ 6.0 一样吗  我看的GDI+的书是C#的  但我用的是VC 6.0 C++编程 
    但是书里写Pen pen(Color.Blue);我却编译不过  只有换成Pen pen(Color::Blue);才可以 为什么呢
      

  2.   

    换VC2005以上的版本吧,VC6就玩玩GDI,少个+算了吧。
      

  3.   

    转过来的:
    问题现象When you build a debug version of a Microsoft Foundation Classes (MFC) application that uses GDI+, you may receive an error message that resembles the following:
    error C2660: ‘Gdiplus::GdiplusBase::operator new’ : function does not take 3 parameters在我们使用GDI+的时候,如果程序是一个MFC程序,并且是在debug模式下,那我们可能会得到如下的错误信息:
    error C2660: ‘Gdiplus::GdiplusBase::operator new’ : function does not take 3 parametersCAUSE
    原因In debug builds, MFC defines a preprocessor macro that expands the new operator to an overloaded new operator that takes two extra parameters. The extra parameters are the source file name and code line number. MFC can use this information to report memory leaks to the programmer when in debug mode. This works for MFC classes because MFC provides overloads for new that accept the extra parameters.However, because this expansion is done by the preprocessor, it affects all usage of the new operator. If any non-MFC classes are used in the project, their new operator is also expanded, even if no suitable overload of new is available in that class. This is what happens in GDI+, and as a result, you receive a compile-time error message.
    在debug模式下,MFC程序要使用一个宏定义来扩展new操作符,使之需要接受两个附加的参数。这两个附加参数分别是源程序的文件名和代码行号。MFC使用它们在debug模式下向程序员报告内存泄漏的信息。MFC类由于重载了new操作符,所以可以正常的与扩展后的new操作符搭配使用。但是,非MFC类则无法与这种扩展的new操作符正常工作。GDI+就属于这种情况。AFX.h中有这样两段,楼主自己对比一下吧,我也搞不太懂了:
    // Memory tracking allocation
    void* AFX_CDECL operator new(size_t nSize, LPCSTR lpszFileName, int nLine);
    #define DEBUG_NEW new(THIS_FILE, __LINE__)
    #if _MSC_VER >= 1200
    void AFX_CDECL operator delete(void* p, LPCSTR lpszFileName, int nLine);
    #endif
    有可能void* AFX_CDECL operator new(size_t nSize, LPCSTR lpszFileName, int nLine);就是MFC重载的new操作符#if defined(_DEBUG) && !defined(_AFX_NO_DEBUG_CRT) 
    // for file name/line number tracking using DEBUG_NEW
    void* PASCAL operator new(size_t nSize, LPCSTR lpszFileName, int nLine); 
    #if _MSC_VER >= 1200
    void PASCAL operator delete(void *p, LPCSTR lpszFileName, int nLine);
    #endif
    #endif