So I'm working on making a finite state machine for an AI class at uni, and I have the weirdest of errors right now, been working on it and nothing seems to get rid of them so hoped someone here can help :)
Basically, in my entity class (the thing that uses the FSM), it doesn't seem to be recognising the State class type, the only thing I could think is the problem now is the order in which I include things but cant seem to get the order right, I know its most likely the smallest of problems, always is so some fresh eyes will be really useful :)
The things to do with ID in entity are commented out as they're a work in progress, as is the rest of my code so inefficient stuff will be sorted out when I can test it again heh
If you need anything else, just say and Ill get right back to you :)
Probably something I should have pointed out sooner I guess :P
and its on any line that uses State or refers to an instance of State after State* state;
they're all things like 'must me a pointer to class type', Entity(int id, State* s) has an error that says Entity(int) already defined, as though the state part isn't in there
the errors I get I know what they mean but not why they are there
So, if anything that says "State" causes an error, why have you given us everything BUT the source code that defines State? We need to see that too, you know ;)
well, it works now :), decided I should just forward declare entity in state as that doesn't do a massive amount with state I don't think
would it be better to forward declare state in entity too or leave that as an include? still a little confused heh, is it only used when there's just a pointer as a parameter or can it be used when you're working with the pointer too?
yeah I know, was just wondering whether the forward declaration is only used when pointers are used as just parameters and return values or if you use them for when you're doing things with pointers or both :)
Forward declaring is used for when you need to resolve a circular dependency at some point, and it works when you use pointers because the compiler doesn't need information about how the class is defined. You do not need to use forward declaring whenever you use pointers; it is used mainly for solving circular dependencies.
In other words, if you use a larger oven to bake a larger cake, you don't need to use larger ovens for all your cakes, just the large cakes.