Thanx, that helped alot, but for some reason my program will not allow me to make a pointer to tState.... which is annoying, since I need them.
I get this error:
Compiler: Default compiler
Building Makefile: "C:\Dev-Cpp\projects\1\Makefile.win"
Executing make...
make.exe -f "C:\Dev-Cpp\projects\1\Makefile.win" all
g++.exe -c main.cpp -o main.o -I"lib/gcc/mingw32/3.4.2/include" -I"include/c++/3.4.2/backward" -I"include/c++/3.4.2/mingw32" -I"include/c++/3.4.2" -I"include"
g++.exe -c StateMan.cpp -o StateMan.o -I"lib/gcc/mingw32/3.4.2/include" -I"include/c++/3.4.2/backward" -I"include/c++/3.4.2/mingw32" -I"include/c++/3.4.2" -I"include"
StateMan.cpp: In member function `void StateManager::Pop()':
StateMan.cpp:44: error: cannot convert `tState' to `tState*' in initialization
StateMan.cpp: In member function `bool StateManager::Process()':
StateMan.cpp:51: error: cannot convert `tState' to `tState*' in initialization
make.exe: *** [StateMan.o] Error 1
Execution terminated
well, it is actually 2 errors.
Here is my new source:
h file:
//Stack.h//This is the StateManager//Originally, I did not want to have to use a State Manager//But since this is an SDKish thing it is good to have one. //It will also keep track of all my states for me, which is //handy.//Austen Higgins-Cassidy#include <cstdlib>#include <string>#include <stack>#ifndef _STATEMAN_H_#define _STATEMAN_H_struct tState{ void (*FunctionPtr)(int flag); tState(); ~tState(); tState(const tState &RHS);};class StateManager{ private: stack<tState> Statelist; public: StateManager(); ~StateManager(); void Push(void (*FunctionPtr)(int)); void Pop(); bool Process(); void Clear(); };#endif
And here is the cpp file
//StateMan.cpp#include <cstdlib>#include <string>#include <stack>using namespace std;#include "StateMan.h"tState::tState(){FunctionPtr = NULL;}tState::~tState(){}tState::tState(const tState &RHS){FunctionPtr = RHS.FunctionPtr;}StateManager::StateManager(){Clear();}StateManager::~StateManager(){Clear();}void StateManager::Push(void (*FunctionPtr)(int)){tState *StatePtr = new tState;StatePtr->FunctionPtr = FunctionPtr;Statelist.push(*StatePtr);}void StateManager::Pop(){tState *StatePtr = Statelist.top();Statelist.pop();delete StatePtr;}bool StateManager::Process(){ tState *StatePtr = Statelist.top(); StatePtr->FunctionPtr;}void StateManager::Clear(){ while(!Statelist.empty()) { Pop(); }}
Thanks...
___________________________________________________Optimists see the glass as Half FullPessimists See the glass as Half EmptyEngineers See the glass as Twice as big as it needs to be