Edit: Just forgot to add "state_manager::
" My bad.
I am trying to create a simple state system. To save some typing and to make things easier to change later, I've put some typedefs in my state_manager.hpp
. The problem is that these typedefs don't seem to be recognized in my state_manager.cpp
.
I get errors like 'element' does not name a type
and strangely 'states' was not declared in this scope
. I am really confused by this.
state_manager.hpp:
#pragma once
#include <stack>
#include <memory>
class state;
class state_manager{
typedef std::unique_ptr<state> element;
typedef std::stack<element> container;
protected:
container states;
public:
void push(const element &to_push);
void pop();
void change(const element &change_to);
};
state_manager.cpp:
#include "state_manager.hpp"
#include "state.hpp"
void push(const element &to_push){
states.push(to_push);
}
void pop(){
states.pop();
}
void change(const element &change_to){
states.pop();
push(change_to);
}