c++编程金典中的程序报错,和书本比较多次没发现问题

来源:百度知道 编辑:UC知道 时间:2024/06/09 06:40:00
第十章的第一个例子,编译后出现
employ2.h(6) : error C2143: syntax error : missing ';' before '<class-head>'
employ2.h(6) : fatal error C1004: unexpected end of file found

程序为
//10.1 p564
//abstract bass class employee
#ifndef EMPLOY2_H
#define EMPLOY2_H

class Employee {
public:
Employee( const char *, const char * );
~Employee(); //
const char * getFirstName() const;
const char * getLastName() const;

//
virtual double earnings() const = 0 ; //
virtual void print() const ; //
private:
char * firstName;
char * lastName;
};

#endif
非常感谢

代码基本可以肯定是没错的

可能是编译器的问题
你用的是什么编译器呢?

或者是你还有其他代码没列出来吧?
错误应该是在其他代码里面的

//10.1 p564
//abstract bass class employee
#ifndef EMPLOY2_H
#define EMPLOY2_H

class Employee {
public:
Employee( const char *, const char * );
~Employee(); //
const char * getFirstName() const;
const char * getLastName() const;

//
virtual double earnings() const = 0 ; //
virtual void print() const ; //
private:
char * firstName;
char * lastName;
};

#endif
这里面有全角空格了

文件最后回车一下