I have a class Faction, which is used to hold data for every NPC faction in the game. One of the things it has is an array<AMyCharacter> of every NPC who belongs to that faction, but each AMyCharacter also needs a variable of type Faction*, so they know which faction they belong to, and who to notify when political events occur. As-is, this is a circular reference, which I know are to be avoided- is there a simple way I can alter my design to avoid this?
You could create a faction manager class just to store the array and related functions, to avoid the issue.
Syntactically, you can just use forward declaration to avoid circular dependency as you only need a pointer to your Faction class.
Oh excellent, I’m going to try the faction manager, and if for some reason that doesn’t work I didn’t even know that forward declarations were a thing- thank you!!