在c ++中,如果包含标题,为什么我得到'不是类型名'错误?

时间:2017-06-09 22:37:55

标签: c++

我有data.h

#ifndef DATA_H_INCLUDED
#define DATA_H_INCLUDED

#include <vector>
#include <string>
#include <iostream>

using namespace std;

class student{
    public:
        string id;
        int points [6] = {0,0,0,0,0,0};
};



#endif // DATA_H_INCLUDED

我有enor.h

#ifndef ENOR_H_INCLUDED
#define ENOR_H_INCLUDED
#include <fstream>
#include <vector>
#include <string>
#include <iostream>
#include "data.h"

using namespace std;

enum status{norm,abnorm};

class enor{
    public:
        /*some voids*/
        Student Current() const { return elem; }
        student elem;
    private:
       /*some voids*/
};


#endif // ENOR_H_INCLUDED

我得到'Student' does not a name a type,但为什么?如果Student calss在enor.h中,我也尝试了,但也是这个错误。我怎么解决这个问题,为什么会这样呢?

1 个答案:

答案 0 :(得分:2)

您的student课程的情况有所不同:

  1. class student - 小写s

  2. Student Current() const - 大写S