我在工程中添加新的类的时候出现错误,具体情况描述如下:
1,要添加的类为:class CDisplayThread: public CExampleThread
其中CExampleThread是工程中的类(CExampleThread 由CWinThread派生而来)
2, 现在我需要添加1所说的类(在CExampleThread.h中添加的),但是手动添加后,运行出现错误,具体如下图所示。
不知是怎么回事,请高手指点!!!
// ExampleThread.cpp : implementation file
//
#include "stdafx.h"
#include "MultiThread.h"
#include "ExampleThread.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CExampleThread
IMPLEMENT_DYNCREATE(CExampleThread, CWinThread)
CExampleThread::CExampleThread()
{
}
CExampleThread::~CExampleThread()
{
}
BOOL CExampleThread::InitInstance()
{
// TODO: perform and per-thread initialization here
return TRUE;
}
int CExampleThread::ExitInstance()
{
// TODO: perform any per-thread cleanup here
return CWinThread::ExitInstance();
}
BEGIN_MESSAGE_MAP(CExampleThread, CWinThread)
//{{AFX_MSG_MAP(CExampleThread)
// NOTE - the ClassWizard will add and remove mapping macros here.
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CExampleThread message handlers
错误信息
--------------------Configuration: MultiThread - Win32 Debug--------------------
Compiling...
ExampleThread.cpp
F:\MultiThread\ExampleThread.cpp(11) : error C2628: 'CDisplayThread' followed by 'char' is illegal (did you forget a ';'?)
F:\MultiThread\ExampleThread.cpp(11) : error C2538: new : cannot specify initializer for arrays
F:\MultiThread\ExampleThread.cpp(17) : error C2665: 'new' : none of the 3 overloads can convert parameter 2 from type 'class CDisplayThread []'
Error executing cl.exe.
MultiThread.exe - 3 error(s), 0 warning(s)