Ich habe da 2 Templates die sich gegenseitig verwenden. Leider klappt das ganze nicht. Hat jemand eine Idee wo der Fehler liegen könnte?
State.h:
Transition.h:
Ausgabe:
Ich benutze übrigens eclipse-cdt, falls das irgendeinen Unterschied macht.
State.h:
Code:
#ifndef STATE_H_
#define STATE_H_
#include "../list/List.h"
#include "Transition.h"
template <class AcceptTokenType> class State {
private:
AcceptTokenType * acceptToken;
List<Transtion<AcceptTokenType> > * transitions;
public:
State(AcceptTokenType * acceptToken);
virtual ~State();
};
#endif /*STATE_H_*/
Transition.h:
Code:
#ifndef TRANSITION_H_
#define TRANSITION_H_
#include "State.h"
template <class StateType> class Transition {
private:
State<StateType> * targetState;
public:
Transition();
virtual ~Transition();
};
#endif /*TRANSITION_H_*/
Ausgabe:
Code:
**** Build of configuration Debug for project sysprog1 ****
gmake -k all
Building file: ../src/fsm/State.cpp
Invoking: GCC C++ Compiler
g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/fsm/State.d" -MT"src/fsm/State.d" -o"src/fsm/State.o" "../src/fsm/State.cpp"
In file included from ../src/fsm/State.h:5,
from ../src/fsm/State.cpp:1:
../src/fsm/Transition.h:8: error: ISO C++ forbids declaration of `State' with no type
../src/fsm/Transition.h:8: error: expected `;' before '<' token
In file included from ../src/fsm/State.cpp:1:
../src/fsm/State.h:10: error: `Transtion' was not declared in this scope
../src/fsm/State.h:10: error: template argument 1 is invalid
../src/fsm/State.h:10: error: expected unqualified-id before '>' token
gmake: *** [src/fsm/State.o] Error 1
Building file: ../src/fsm/Transition.cpp
Invoking: GCC C++ Compiler
g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/fsm/Transition.d" -MT"src/fsm/Transition.d" -o"src/fsm/Transition.o" "../src/fsm/Transition.cpp"
In file included from ../src/fsm/Transition.h:4,
from ../src/fsm/Transition.cpp:1:
../src/fsm/State.h:10: error: `Transtion' was not declared in this scope
../src/fsm/State.h:10: error: template argument 1 is invalid
../src/fsm/State.h:10: error: expected unqualified-id before '>' token
gmake: *** [src/fsm/Transition.o] Error 1
gmake: Target `all' not remade because of errors.
Build complete for project sysprog1
Ich benutze übrigens eclipse-cdt, falls das irgendeinen Unterschied macht.