首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

帮忙看看,error C2143: 语法异常 : 缺少“;”(在“using”的前面)

2012-03-12 
帮忙看看,error C2143: 语法错误 : 缺少“”(在“using”的前面)错误:boldparagraph.cpp(5) : error C2143:

帮忙看看,error C2143: 语法错误 : 缺少“;”(在“using”的前面)
错误:boldparagraph.cpp(5) : error C2143: 语法错误 : 缺少“;”(在“using”的前面)
C++高级编程中的一个例子。讲装饰者模式的。其中,Paragraph是BoldParagraph的父类,父类的声明和定义都没有问题,
有问题的是子类BoldParagraph:


-----------------------------头文件中--------------------------------
// BoldParagraph.h
#pragma once
#include "Paragraph.h"
#include <string>
using namespace std;

class BoldParagraph : public Paragraph
{
public:
BoldParagraph(const Paragraph& inParagraph) : Paragraph("unassigned"), mParagraph(inParagraph){}

virtual string getText() const;
protected:
const Paragraph& mParagraph;
}


------------------------报错的CPP文件-----------------------------------
// BoldParagraph.cpp
#include "Paragraph.h"
#include "BoldParagraph.h"
#include <string>
using namespace std;

string BoldParagraph::getText() const
{
return ("<B>" + mParagraph.getText() + "</B>");
}


麻烦帮忙看看


[解决办法]
检查一下"Paragraph.h" 
或"BoldParagraph.h" 
文件的最后声明是否少了一个分号 

[解决办法]
一眼就看到
class BoldParagraph : public Paragraph 

public: 
BoldParagraph(const Paragraph& inParagraph) : Paragraph("unassigned"), mParagraph(inParagraph){} 

virtual string getText() const; 
protected: 
const Paragraph& mParagraph; 
};<====这里少分好
[解决办法]
是不是定义class最后少了分号了?

热点排行