Here''s the story old friends... Right now I''ve got a fairly intense (by my standard anyway...
)class going, so to illustrate this, I will use the simple class found in exibit A:
class Pineapple
{
public:
int X;
int Y;
int Add(void) {return(X + Y);}
int (*Zebra)();
};
Now I hope you have noted the function pointer Zebra(). So, now I want the function to be user-defineable such as follows:
int Sword()
{
}
.
.
.
Zebra = Sword;
So this shouldn''t be problem, right?
Well here is how I want to define Sword:
int Sword()
{
return (X - Y);
}
I guess I shouldn''t have spent all this time to illustrate such a simple question, too late now though... Anyway, I want to use the X and Y from the class, but this seems to annoy the compiler simply because it has no idea what these vaibles are...why can''t it just know?!? So, how do I go about ammending this wee problem? It seems it me that this is a very C way of doing things and there must be some appropriate way to accomplish this in C++. Anyway, I desperately await the elusive answer!
Thank you for your time and such...
-> Briar LoDeran <-