我正在尝试修改用旧版本的 Visual Studio 编写的项目。我现在使用 Visual Studio 2010。当我打开项目时,它会自动转换为 2010 格式。但是,当我构建它时出现以下错误:
Error 1 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\x\dcd\dcdchild.h 22 1
有问题的文件很小:
// dcdchild.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CDCDChildWnd frame
class CDCDChildWnd : public CMDIChildWnd
{
DECLARE_DYNCREATE(CDCDChildWnd)
protected:
CDCDChildWnd(); // protected constructor used by dynamic creation
// Attributes
public:
// Operations
public:
// Implementation
protected:
virtual ~CDCDChildWnd();
virtual CDCDChildWnd::PreCreateWindow(CREATESTRUCT& cs);
// Generated message map functions
//{{AFX_MSG(CDCDChildWnd)
// NOTE - the ClassWizard will add and remove member functions here.
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
有问题的行是:
virtual CDCDChildWnd::PreCreateWindow(CREATESTRUCT& cs);
我查阅了 CREATESTRUCT 的定义,它是:
typedef struct tagCREATESTRUCT {
LPVOID lpCreateParams;
HINSTANCE hInstance;
HMENU hMenu;
HWND hwndParent;
int cy;
int cx;
int y;
int x;
LONG style;
LPCTSTR lpszName;
LPCTSTR lpszClass;
DWORD dwExStyle;
} CREATESTRUCT, *LPCREATESTRUCT;
所以它确实包含变量类型 int。问题是,我该如何解决?
最佳答案
声明 virtual CDCDChildWnd::PreCreateWindow(CREATESTRUCT& cs);
无效。它应该是这样的:
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
关于c++ - CREATESTRUCT 错误 C4430 : missing type specifier - int assumed. 注意 : C++ does not support default-int c:\x\dcd\dcdchild. h 22 1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29278256/