“类别”未命名类型

时间:2019-07-09 16:51:28

标签: c++

我目前停留在抽象计算器的C ++代码上。问题是我有一个抽象类标头要用自己的派生类覆盖。但是,编译器坚持要给我标题上的错误。我已经检查了所有包含项,这似乎没有错。谁能给我一点光?

我的标题:

#include <iostream>
#include "Calculator.hpp"

#ifndef CALCULATORIURI_H
#define CALCULATORIURI_H

class CalculatorIuri: public Calculator{
    public:
        CalculatorIuri();


        CalculatorKeyboard* getCalculatorKeyboard();
        Cpu* getCpu();
        Screen* getScreen(void);
        void receive(Operation);
        void receiveDigit(Digit);
        void receiveClear();

        int value;



};

#endif

代码:

#include "CalculatorIuri.hpp"


CalculatorIuri::CalculatorIuri(){

}

Screen* CalculatorIuri::getScreen(void){

}
//and it goes on...

编译器不断告诉我“ CalculatorIuri”未命名类型,但已将其声明为类。

具有纯抽象方法的原始代码:

//no includes before, just another abstract classes definitions and header guard
class Calculator: public CalculatorReceiver {
public:
  virtual CalculatorKeyboard * getCalculatorKeyboard() = 0;
  virtual Cpu * getCpu() = 0;
  virtual Screen * getScreen() = 0;
};
//and goes on...

编辑:

奇怪的事实是,其他派生类似乎也可以正常工作

#ifndef SCREENIURI_H
#define SCREENIURI_H

#include <iostream>
#include "Calculator.hpp"

class ScreenIuri: public Screen{


    public:
        ScreenIuri();

        void clear(void);
        void addDigit(Digit);

};

#endif

edit2:

我只是重写了标头,由于某种原因,它像其他标头一样工作,谢谢大家。

新标题:

#ifndef CALCULATORIURI_H
#define CALCULATORIURI_H

#include <iostream>
#include "Calculator.hpp"

class CalculatorIuri:public Calculator{

    public:
        CalculatorIuri();
        CalculatorKeyboard * getCalculatorKeyboard();
        Cpu * getCpu();
        Screen * getScreen();
        int value;


};

#endif

0 个答案:

没有答案