类名是:CLine
我想在MyMDIDoc类里面用到这个CLine类,于是我在MyMDIDoc的头文件里面加入这个类:
于是我在这里面添加了:
// MyMDIDoc.cpp : implementation of the CMyMDIDoc class
//#include "stdafx.h"
#include "MyMDI.h"#include "MyMDIDoc.h"
#include "CntrItem.h"
#include "SrvrItem.h"
#include "Line.h" //这个是我添加要用到的类#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
编译的时候就出现6个错误了!:
f:\myvc\mymdi\mymdidoc.h(41) : error C2143: syntax error : missing ';' before '*'
f:\myvc\mymdi\mymdidoc.h(41) : error C2501: 'CLine' : missing storage-class or type specifiers
f:\myvc\mymdi\mymdidoc.h(41) : error C2501: 'AddLine' : missing storage-class or type specifiers
F:\MyVC\MyMDI\MyMDIDoc.cpp(148) : error C2143: syntax error : missing ';' before '*'
F:\MyVC\MyMDI\MyMDIDoc.cpp(148) : error C2501: 'CLine' : missing storage-class or type specifiers
F:\MyVC\MyMDI\MyMDIDoc.cpp(149) : error C2501: 'AddLine' : missing storage-class or type specifiers
我想在MyMDIDoc类里面用到这个CLine类,于是我在MyMDIDoc的头文件里面加入这个类:
于是我在这里面添加了:
// MyMDIDoc.cpp : implementation of the CMyMDIDoc class
//#include "stdafx.h"
#include "MyMDI.h"#include "MyMDIDoc.h"
#include "CntrItem.h"
#include "SrvrItem.h"
#include "Line.h" //这个是我添加要用到的类#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
编译的时候就出现6个错误了!:
f:\myvc\mymdi\mymdidoc.h(41) : error C2143: syntax error : missing ';' before '*'
f:\myvc\mymdi\mymdidoc.h(41) : error C2501: 'CLine' : missing storage-class or type specifiers
f:\myvc\mymdi\mymdidoc.h(41) : error C2501: 'AddLine' : missing storage-class or type specifiers
F:\MyVC\MyMDI\MyMDIDoc.cpp(148) : error C2143: syntax error : missing ';' before '*'
F:\MyVC\MyMDI\MyMDIDoc.cpp(148) : error C2501: 'CLine' : missing storage-class or type specifiers
F:\MyVC\MyMDI\MyMDIDoc.cpp(149) : error C2501: 'AddLine' : missing storage-class or type specifiers
解决方案 »
- CSDN老是卡...
- 急!!电子白板中的图形识别
- VS2010 使用的时候很卡,有啥办法可以解决一下的吗?
- 初级问题,向导建的 dialog based工程,确认按钮的id是 IDOK,其对应的数字是多少?在哪定义的?
- windows下如何判断平台为32bit或者64bit
- 急! 我的mfc项目中原来没有数据库功能,现在想添加access 数据库功能!
- 进程间的通信
- 如何在EVC中引用Web service?
- 请问activeX能否用在控制台程序当中?
- 模式对话框的一个按钮中能不能调用CWinApp类的OnFileNew函数,如何调用?
- 用vc++标准模版库中的pair模版 要include什么头文件?
- 急:如何用显示链接方式写封装类的dll,以及如何在别的应用程序中调用它。
你的Line.h文件有问题 查查笔误 时候少;号等等
CLine* AddLine (CPoint ptFrom,CPoint ptTo);
这句有问题啊。
*号表示指针,那么ADDLINE只是一个指针,还没空间呢。
[email protected]
或者加入class CDrawGraph;而你的程序是在MyMDIDoc.cpp中加入的。我模拟了一下应该可以。
你再仔细一点应是没有什么问题的
你说得是不是<<Visual C++6.0高级开发教程>>这本书
做
我也做过这本书
没有什么错误呀
//
/////////////////////////////////////////////////////////////////////////////#if !defined(AFX_MYMDIDOC_H__7FE79C6F_808F_4DCE_991E_01848DF65810__INCLUDED_)
#define AFX_MYMDIDOC_H__7FE79C6F_808F_4DCE_991E_01848DF65810__INCLUDED_#include "line.h" // Added by ClassView
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class CMyMDISrvrItem;class CMyMDIDoc : public COleServerDoc
上面那些是我复制下来的东西!按你的意思是说在这里的哪个地方添加这句话啊?我曾经添加在这里的,它还是提示14个错误!:
F:\MYVC\MyMDI\MyMDIDoc.cpp(152) : error C2065: 'CLine' : undeclared identifier
F:\MYVC\MyMDI\MyMDIDoc.cpp(152) : error C2065: 'pLine' : undeclared identifier
F:\MYVC\MyMDI\MyMDIDoc.cpp(152) : error C2660: 'Cline::Cline' : function does not take 2 parameters
F:\MYVC\MyMDI\MyMDIDoc.cpp(156) : error C2065: 'm_oalines' : undeclared identifier
F:\MYVC\MyMDI\MyMDIDoc.cpp(156) : error C2228: left of '.Add' must have class/struct/union type
F:\MYVC\MyMDI\MyMDIDoc.cpp(161) : error C2317: 'try' block starting on line '154' has no catch handlers
F:\MYVC\MyMDI\MyMDIDoc.cpp(161) : error C2065: 'Catch' : undeclared identifier
F:\MYVC\MyMDI\MyMDIDoc.cpp(161) : error C2065: 'CMemory' : undeclared identifier
F:\MYVC\MyMDI\MyMDIDoc.cpp(161) : error C2146: syntax error : missing ')' before identifier 'Exception'
F:\MYVC\MyMDI\MyMDIDoc.cpp(161) : error C2059: syntax error : ')'
F:\MYVC\MyMDI\MyMDIDoc.cpp(162) : error C2143: syntax error : missing ';' before '{'
F:\MYVC\MyMDI\MyMDIDoc.cpp(169) : error C2541: delete : cannot delete objects that are not pointers
F:\MYVC\MyMDI\MyMDIDoc.cpp(172) : error C2065: 'perr' : undeclared identifier
F:\MYVC\MyMDI\MyMDIDoc.cpp(172) : error C2227: left of '->Delete' must point to class/struct/union谢谢各位!
Cline : 要大写 CLine
因为你的构造函数 void CLine (CPoint ptFrom,CPoint ptTo);用的是大写。
反正你要同一,要大写就全部大写。
Cline *pLine=new CLine(ptFrom,ptTo);
CLine 也写成一样的。class Cline : public CObject
{
public:
void Draw (CDC *pDC);
void CLine (CPoint ptFrom,CPoint ptTo);
Cline(); //构造函数
virtual ~Cline(); //虚函数private:
CPoint m_ptFrom; //起点
CPoint m_ptTo; //目标点
};
m_oalines 不知从那里来得。
你要好好看看 c++ 补一下基础的东西了!
试问一个刚入门的怎么能看出来...........