error C2653: 'CMy01App' : is not a class or namespace name

gvdong 2010-10-17 09:26:13
#include<AfxWin.h>
class CMy01App :: public CWinApp
{
public:
virtual BOOL InitInstance();

};
class CMyWindow :: public CFrameWnd
{
public:
CMyWindow();
protected:
afx_msg void OnPaint ();
DECLARE_MESSAGE_MAP();
};




BOOL CMy01App::InitInstance()
{
m_pMainWnd= new CMyWindow;
m_pMainWnd->ShowWindow(m_nCmdShow);
m_pMainWnd->UpdateWindow();
return TRUE;

}


BEGIN_MESSAGE_MAP(CMyWindow,CFrameWnd)
ON_WM_PAINT()
END_MESSAGE_MAP()
CMyWindow::CMyWindow()
{
Create(NULL,_T("The Hello Application"));

}
void CMainWindow::OnPaint()
{
CPaintDC dc(this);
dc.MoveTo(10,20);
dc.LineTo(100,200);
}



想知道为什么会这样:error C2653: 'CMy01App' : is not a class or namespace name
...全文
170 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
libinfei8848 2010-10-17
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 gules 的回复:]
class CMyApp :: public CWinApp
改为
class CMyApp : public CWinApp

后面一样,继承是 : 而不是 ::
[/Quote]

恩,说的正确
gules 2010-10-17
  • 打赏
  • 举报
回复
class CMyApp :: public CWinApp
改为
class CMyApp : public CWinApp

后面一样,继承是 : 而不是 ::
gvdong 2010-10-17
  • 打赏
  • 举报
回复
CMainWindow是窗口类派生的,CMyApp是从应用程序类派生的,不行啊,我试了
#include<AfxWin.h>
class CMyApp :: public CWinApp
{
public:
virtual BOOL InitInstance();

};
class CMmainWindow :: public CFrameWnd
{
public:
CMainWindow();
protected:
afx_msg void OnPaint ();
DECLARE_MESSAGE_MAP();
};




BOOL CMyApp::InitInstance()
{
m_pMainWnd= new CMyWindow;
m_pMainWnd->ShowWindow(m_nCmdShow);
m_pMainWnd->UpdateWindow();
return TRUE;

}


BEGIN_MESSAGE_MAP(CMyWindow,CFrameWnd)
ON_WM_PAINT()
END_MESSAGE_MAP()
CMainWindow::CMainWindow()
{
Create(NULL,_T("The Hello Application"));

}
void CMainWindow::OnPaint()
{
CPaintDC dc(this);
dc.MoveTo(10,20);
dc.LineTo(100,200);
}
zyrr159487 2010-10-17
  • 打赏
  • 举报
回复
。。。你这个是直接拷贝了代码吧,'CMy01App' 换成CMainWindow试试看
gvdong 2010-10-17
  • 打赏
  • 举报
回复
帮帮忙

64,282

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧