I'm current stuck on a c++ code of abstracting a calculator. Thing is I have a abstract class header to override with my own derivative. However, the compiler insist in giving me the error on the title. I already had checked all the includes and it does not seems to be wrong. Can anyone give me some light?
My header:
#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
The code:
#include "CalculatorIuri.hpp"
CalculatorIuri::CalculatorIuri(){
}
Screen* CalculatorIuri::getScreen(void){
}
//and it goes on...
The compilator keeps telling me that "CalculatorIuri" does not name a type, but it was already declared as a class.
The original code with the pure abstract methods:
//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...
edit:
Strange fact is that other derivative classes seems to work fine, like this one
#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:
I just rewritten the header and for some reason it worked like the other ones, thank you everyone for the time.
New header:
#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