读书人

急救请高手帮小弟我看看关于vector有

发布时间: 2012-03-27 13:44:24 作者: rapoo

急救,请高手帮我看看关于vector问题
请教高手:
我用的是VC++6.0。先看下代码
#if !defined(AFX_PAGE4_H__35A2252E_4D6E_45F2_98CB_85324DAC6482__INCLUDED_)
#define AFX_PAGE4_H__35A2252E_4D6E_45F2_98CB_85324DAC6482__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// Page4.h : header file
//
#include <vector>
using namespace std;
/////////////////////////////////////////////////////////////////////////
// CPage4 dialog
class CPage4 : public CDialog
{
// Construction
public:
CPage4(CWnd* pParent = NULL); // standard constructor
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CPage4)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_PAGE4_H__35A2252E_4D6E_45F2_98CB_85324DAC6482__INCLUDED_)

我重载了CDialog类,希望得到自己的对话框,我想在新的对话框中使用vector容器来管理一些数据,但当我包含 <vector> 时,出现以下错误,请高手帮我分析下:
Compiling...
MainFrm.cpp
c:\program files\microsoft visual studio\vc98\include\new(35) : error C2061: syntax error : identifier 'THIS_FILE '
c:\program files\microsoft visual studio\vc98\include\new(35) : error C2091: function returns function
c:\program files\microsoft visual studio\vc98\include\new(35) : error C2809: 'operator new ' has no formal parameters
c:\program files\microsoft visual studio\vc98\include\new(36) : error C2061: syntax error : identifier 'THIS_FILE '
c:\program files\microsoft visual studio\vc98\include\new(37) : error C2091: function returns function
c:\program files\microsoft visual studio\vc98\include\new(37) : error C2556: 'void *(__cdecl *__cdecl operator new(void))(unsigned int,const struct std::nothrow_t &) ' : overloaded function differs only by return type from 'void *(__cdecl *__cdecl op
erator new(void))(unsigned int) '
c:\program files\microsoft visual studio\vc98\include\new(35) : see declaration of 'new '
c:\program files\microsoft visual studio\vc98\include\new(41) : error C2061: syntax error : identifier 'THIS_FILE '
c:\program files\microsoft visual studio\vc98\include\new(42) : error C2091: function returns function
c:\program files\microsoft visual studio\vc98\include\new(42) : error C2556: 'void *(__cdecl *__cdecl operator new(void))(unsigned int,void *) ' : overloaded function differs only by return type from 'void *(__cdecl *__cdecl operator new(void))(unsig


ned int) '
c:\program files\microsoft visual studio\vc98\include\new(35) : see declaration of 'new '
c:\program files\microsoft visual studio\vc98\include\new(42) : error C2809: 'operator new ' has no formal parameters
c:\program files\microsoft visual studio\vc98\include\new(42) : error C2065: '_P ' : undeclared identifier
c:\program files\microsoft visual studio\vc98\include\memory(16) : error C2061: syntax error : identifier 'THIS_FILE '
c:\program files\microsoft visual studio\vc98\include\memory(17) : error C2091: function returns function
c:\program files\microsoft visual studio\vc98\include\memory(17) : error C2784: 'void *(__cdecl *__cdecl operator new(void))(unsigned int,class std::allocator <`template-parameter257 '> &) ' : could not deduce template argument for 'void *(__cdecl *)(u
nsigned int,class std::allocator <_Ty> &) ' from 'void *(__cdecl *)(unsigned int) '
c:\program files\microsoft visual studio\vc98\include\memory(17) : error C2785: 'void *(__cdecl *__cdecl operator new(void))(unsigned int,class std::allocator <`template-parameter257 '> &) ' and 'void *(__cdecl *__cdecl operator new(void))(unsigned int
) ' have different return types
c:\program files\microsoft visual studio\vc98\include\memory(16) : see declaration of 'new '
c:\program files\microsoft visual studio\vc98\include\memory(17) : error C2809: 'operator new ' has no formal parameters
c:\program files\microsoft visual studio\vc98\include\memory(20) : error C2954: template definitions cannot nest

我对此错误不知道指什么,请高手帮我分析下,谢谢!

[解决办法]
下载新的Microsoft SDK
[解决办法]
你的 #include <...> 一定是放在cpp文件中的这段代码的后面了,把 #include <...> 提到这段代码的前面去就行了,看看这段代码的意思就知道它在debug版重载了new操作符。

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
[解决办法]
我运行了一下,没有错误啊!
[解决办法]
我遇到了你同样的错误.
一模一样,所有症状.

你把#include <vector> 放在stdafx.h,再Rebuild All,试试.
我这样一放,问题解决.

读书人网 >VC/MFC

热点推荐