syntax error missing ';' before ''的解决办法

syntax error missing ';' before ''的解决办法


2024年4月15日发(作者:怎么把d盘多余的空间分给c盘)

在VC编程过程中我们经常会遇到这样的错误提示信息error C2143: syntax error :

missing ';' before '*',即在“*”号之前少了“;”。究竟是什么原因?

背景:当在MainFrame类中包含CView.h文件时会出现编译错误。

下面我们首先看看编译器的错误提示信息:

--------------------Configuration: splitter - Win32 Debug--------------------

f:c++praticevctestsplittersplitterview.h(21) : error C2143: syntax error :

missing ';' before '*'

f:c++praticevctestsplittersplitterview.h(21) : error C2501: 'CSplitterDoc' :

missing storage-class or type specifiers

f:c++praticevctestsplittersplitterview.h(21) : error C2501: 'GetDocument' :

missing storage-class or type specifiers

Error executing .

- 3 error(s), 0 warning(s)

我们可以在第一条错误提示上双击鼠标左键,VC++将在代码编辑窗口打开CView类

头文件,并定位到如图中光标所示位置。

这个错误在程序开发中会经常遇到,实际上,并不是错误信息所说的那样要在*号前加

一个分号,而是程序不认识CSplitterDoc这个类。我们知道,C++程序在编译时,只有源

文件参与编译,我们在CMainFrame类的源文件前部加入了包含splitterView.h文件的代

码#include "splitterView.h",因此,在编译CMainFrame类得源文件时,当遇到这行语

句,就会展开splitterView.h文件的内容,但该文件中引用了尚未定义的splitterDoc.h类,

因此编译器就会报告上述错误信息。那为什么视类的源文件包含它的头文件,在编译时没

有出错呢?可以先看看splitterView类得源文件,下面是她开始的几行语句:

[cpp] view plaincopyprint?

1. // : implementation of the CSplitterView class


发布者:admin,转转请注明出处:http://www.yc00.com/xitong/1713189373a2200520.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信