A small challenge
Posted: Tue Dec 21, 2010 9:24 am
Hi masters,
I have a very small problem, I bet others would have already thought of a better solution to this, so I'll try my luck and post my problem. Sorry, this isn't Irrlicht related but I don't know where else I could post this so I posted it here.
Without much ado, here's the code (greatly condensed):
as you may have noticed, the part
is the problem. This is because I used flowControl which isn't declared yet. The problem is, I need to call functions of flowControl from within the function that was dynamically called by flowControl. Something like this:
I hope I was able to convey my intention, i.e. to call a function that is from within flowControl class from within Menu::Main. Anybody got a working solution for that challenging task? I hope you could enlighten me.
Thanks and more power to everyone! ^_^ If what I've done (i.e. post this problem here) is wrong, please forgive me and kindly ignore or delete this topic.
I have a very small problem, I bet others would have already thought of a better solution to this, so I'll try my luck and post my problem. Sorry, this isn't Irrlicht related but I don't know where else I could post this so I posted it here.
Without much ado, here's the code (greatly condensed):
Code: Select all
namespace ykIrr
{
typedef int (*flowControlFunction)(ykIrr::tIrrlichtEngine, ykIrr::sceneClass, flowControl );
class flowControl
{
private:
typedef struct tState
{
flowControlFunction f; // function
} tState;
tState S;
public:
int addState( flowControlFunction f)
{
S.f = f;
return 1;
}
};
}
Code: Select all
typedef int (*flowControlFunction)(ykIrr::tIrrlichtEngine, ykIrr::sceneClass, flowControl );
Code: Select all
namespace Menu
{
int Main(ykIrr::tIrrlichtEngine I, ykIrr::sceneClass SC, ykIrr::flowControl )
{
//fC.setState("main");
return 1;
}
}
int main()
{
ykIrr::flowControl fC;
fC.addState( &Menu::Main );
}
Thanks and more power to everyone! ^_^ If what I've done (i.e. post this problem here) is wrong, please forgive me and kindly ignore or delete this topic.