/* class votes to be the one to be picked*/
union union_base {
BaseEntity baseEntity;
Entity entity;
EmptyPawn emptyPawn;
WeaponEntity weapon;
WalkingEntity walkingEntity;
IntelligentEntity intelligentEntity;
PlayerCharacter playerCharacter;
StaticMesh staticMesh;
While I'm here: #include <stdio.h>
That's a bad sign.
In C++ we use <cstdio> instead, and we don't ever like to do that; what do you need from that header that you can't do better with C++?
Also, union. That's a bad sign too. This looks like you're implementing polymorphism yourself, manually. C++ does that for you if you just work with it.
I'm having all kinds of problems with my include files. Any suggestions on how to straighten them out?
Some suggestions:
> Only include header files.
> Every header file must include a unique header guard.
> Do not rely on transitive or indirect inclusions: include exactly the files you need on a file-by-file basis.
> Factor out code to eliminate cyclical dependencies (e.g., a.hpp depends on b.hpp depends on a.hpp), if any exist.
> If a source file has a corresponding header, include the corresponding header file first in the source file.
> Split your code up in the way that best supports your project's physical and logical structure. In particular, you need not place one class per file.
> Not every entity ought to be defined in a header file (or have external linkage). If a component isn't required elsewhere, give it internal linkage and define it in the source file.
class BaseEntity //: public SceneGraphNode
{
public:
void dispatch(Message *msg); //see message manager for instructions
//class entity is the foundation of messenger
//dispatch processes in the Finite State Machine
void notify(); //notifies the dynamic BSP that a change occurred to
//the mesh and it has to rebalance
//in this case you can use FLINCH in place of the plain vanilla finite state machine
int owner_index; //identity for message
union union_base union_joined;
except for the union that just says "Field has incomplete type union union_base"
OK let's scrap the union idea. I wasn't too fond of it anyway.
This is the problem I have got to solve.
I have a class called Advisor which has two members, a Message class message and a BaseEntity class called event.
THe BaseEntity class has an inheritance tree going from Entity Class to Intelligent Class to PlayerCharacter at the most. Each of the entity classes h as its own finite state machine in it. My problem is storing the entity class. I need to have any one of the entity classes in the Advisor's event member variable.
unions are sort of C-ish. With the ban on the union hack (its been deemed undefined behavior), I have not seen a lot of use for them in c++. Basically the only thing they were good at was killed. Its probably best if you avoid them.