Inheritance error

So i have two classes, one is an abstract "Servicio.h", and the class "Aparato.h" which inherits from it, but I'm getting an error which does not let me create an Aparato object in the main, even though I included Servicio.h. I omitted the information inside, I have no clue why its not working.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#ifndef Servicio_h
#define Servicio_h
class Servicio
{
protected:
    
public:
    
};
#endif /* Servicio_h */


#ifndef Aparato_h
#define Aparato_h
#include "Servicio.h"
class Aparato:public Servicio
{
private:
    
public:

};
#endif /* Aparato_h */ 

The code looks fine. What error do you get?

does not let me create an Aparato object in the main, even though I included Servicio.h

Include Aparato.h then?
Last edited on
The purpose of the exercise is Inheritance/Polymorphism so thats why I'm not including Aparato.h, the error I get if I try to make an Aparato object is "unknown type name 'Aparato'", it just does not recognize it at all.
Last edited on
Ok, so I put them both classes in the same .h file and it worked... Not sure what the problem was.
integralfx is right. If the Aparato class is defined in Aparato.h but you don't include this header file there is no way the compiler could know about the Aparato class.
Yeah, he was right, I messed up and was including Servicio.h, when I should be including Aparato.h, thanks :)
Topic archived. No new replies allowed.