Why won’t my simple c++ code compile? get undeclared identifier errors.
I can’t see the problem
Thanks a lot
int _tmain(int argc, _TCHAR* argv[])
{
StateMachine<States,Triggers> sm;
return 0;
}
enum States
{
New,
Complete
};
enum Triggers
{
CreateNew,
MoveToComplete
};
template <class TState, class TTrigger> class StateMachine
{
public:
StateMachine();
};
You have to forward-declare the
StateMachineclass, otherwise the compiler does not now how to handle that identifier as it hasn’t been told to him what it actually is, yet, or at least, that it exists.