Hi! I'm trying to make an Game Engine with C++ (and learn how this language works) and I'm having a problem in use in my program body an object instanced inside a class. Can somebody help me? Thank you!
EDIT: I'm trying to do this to just need call the Start of the Aura class to use the engine, and not of all classes.
If you want objAuraGrafico to be a AuraGrafico* you should change line 16 to static AuraGrafico* objAuraGrafico;, assuming you still want it to be static. Before the Aura class definition you put a forward declaration class AuraGrafico; to tell that AuraGrafico is a class type (this is needed to declare the pointer). static member variables are only declared inside the class definition so you need to define it somewhere else. In aura.cpp you put AuraGrafico*Aura::objAuraGrafico;
Line 16 in aura.cpp you are creating a local AuraGrafico object that will not exist outside that function. I don't think that is what you want. You probably want to dynamically allocate an AuraGrafico object objAuraGrafico = new AuraGrafico;.
The way you use it in main makes me unsure if you really want objAuraGrafico to be static. Why do you make it static? Maybe it doesn't need to be pointer either.
What I wanted is to have access to objAuraGrafico just by the object objAura. I changed my code according what you said and what I saw in an example a it's working now!
But I want to know if there is some concept error (I think its not), like the include that I done inside the file aura.h. I read once in the internet that you can't include files in .H, just in .CPP, is that right? =O
I read once in the internet that you can't include files in .H, just in .CPP, is that right?
No that's not right but it's good to try to avoid includes in headers because you easily get circular dependencies. Sometimes you have to include in the header. Forward declaration is only enough if you all you have is pointers to the type so in aura.h you have to aura_grafico.h because objAuraGrafico is no pointer.