小编and*_*rew的帖子

重新定义头文件中的类

我正在尝试编译我的代码g++,但它抛出这个编译错误:

Enrollment.h:3:7: error: redefinition of class sict::Enrollment
Enrollment.h:3:7: error: previous definition of class sict::Enrollment
Run Code Online (Sandbox Code Playgroud)

我的Enrollment.h:

namespace sict{
class Enrollment{
  private:
    char _name[31];
    char _code[11];
    int _year;
    int _semester;
    int _slot;
    bool _enrolled;
  public:
    Enrollment(const char* name , const char* code, int year, int semester ,  int time );
    Enrollment();
    void set(const char* , const char* , int ,int,  int , bool = false );

    void display(bool nameOnly = false)const;
    bool valid()const;
    void setEmpty();
    bool isEnrolled() const; …
Run Code Online (Sandbox Code Playgroud)

c++ class redefinition

2
推荐指数
1
解决办法
2716
查看次数

标签 统计

c++ ×1

class ×1

redefinition ×1