Hi!
I am having problems with two Classes. In Class Position one method received the instance of Class Swarm.
But in Class Swarm I use the Class Position as part of its private atributes.
This gives me a linker error saying I need a library to link to, but there is no library.
I've been trying to use forward declaration to call the Swarm object from the positionUpdate method but I get errors.
Additionally, I can't access the Swarm methods to get or set its properties.
Not quite.
Option 1: Forward declaring and inlining the function inside the Header causes an error C2027: use of undefined type 'swarm'.
Option 2: Not inlining the function and putting it in the cpp but forward declare it (as it was before) causes a linking problem (same, can't find the functions).
Option 3: As it is now, in another header file as an inline function that includes the header from the forward declaring class. Gives error C2027: use of undefined type 'swarm'
So in Position you forward declare swarm, then in an implementation file (not the bottom of the header file) you #include "swarm.h" and do your updatePosition implementation there?
In the swarm .cpp you have everything implemented for class swarm?
In other words, you have fully implemented these classes somewhere?
Option 2: Not inlining the function and putting it in the cpp but forward declare it (as it was before) causes a linking problem (same, can't find the functions).
You did #include in the cpp for the forward declared class right?