【发布时间】:2014-12-11 12:12:18
【问题描述】:
我不是一个熟练的 C++ 程序员,我在一个 Visual Studio 解决方案中得到了一个非常大的项目(实际上是 24 个)。
我几乎在所有项目中都遇到了这个错误,我不知道如何解决它。
当我双击错误时,它会将我带到这个地方:
for( int i = 0; i < nNewSize; i++ )
#pragma push_macro("new")
#undef new
::new((void*)(m_pData+i))TYPE;
#pragma pop_macro("new")
构建顺序输出给了我这个:
c:\program files (x86)\microsoft visual studio 11.0\vc\atlmfc\include\afxtempl.h(403): error C2661: 'operator new' : no overloaded function takes 2 arguments
19> c:\program files (x86)\microsoft visual studio 11.0\vc\atlmfc\include\afxtempl.h(368) : while compiling class template member function 'void CArray<TYPE,ARG_TYPE>::SetSize(INT_PTR,INT_PTR)'
19> with
19> [
19> TYPE=D2D1_GRADIENT_STOP,
19> ARG_TYPE=D2D1_GRADIENT_STOP
19> ]
19> c:\program files (x86)\microsoft visual studio 11.0\vc\atlmfc\include\afxtempl.h(643) : see reference to function template instantiation 'void CArray<TYPE,ARG_TYPE>::SetSize(INT_PTR,INT_PTR)' being compiled
19> with
19> [
19> TYPE=D2D1_GRADIENT_STOP,
19> ARG_TYPE=D2D1_GRADIENT_STOP
19> ]
19> c:\program files (x86)\microsoft visual studio 11.0\vc\atlmfc\include\afxtempl.h(355) : while compiling class template member function 'CArray<TYPE,ARG_TYPE>::~CArray(void)'
19> with
19> [
19> TYPE=D2D1_GRADIENT_STOP,
19> ARG_TYPE=D2D1_GRADIENT_STOP
19> ]
19> c:\program files (x86)\microsoft visual studio 11.0\vc\atlmfc\include\afxrendertarget.h(1028) : see reference to class template instantiation 'CArray<TYPE,ARG_TYPE>' being compiled
19> with
19> [
19> TYPE=D2D1_GRADIENT_STOP,
19> ARG_TYPE=D2D1_GRADIENT_STOP
19> ]
afxrendertarget.h 在 1028 处有这一行
CArray<D2D1_GRADIENT_STOP, D2D1_GRADIENT_STOP> m_arGradientStops;
我试图在我的脚本中注释以下行:
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
但它没有效果。
请帮帮我!
【问题讨论】:
-
我的建议是立即逃跑。这个项目只会带来痛苦。
-
是的,我知道。这是我工作的第二周,我开始感到非常沮丧。我已经解决了很多错误,现在我就在这一点上。
-
我想知道什么样的组织会为没有经验的 C++ 程序员提供包含 24 个项目的解决方案。这么多代码,不懂C++就无法维护C++。
标签: c++ operator-overloading new-operator