quote:Original post by Roof Top Pew Wee
1: Just because a function is in a class rather than outside of one, does it really chage it?
Yes, functions outside of classes and non-static methods have different calling-conventions
quote:
I mean, ovbiously it does in my case, but isn''t there a way to just have a typedef for both functions in and outside of classes?
Not really (unless the method in the class is static, but that seems to not be such a good option for you).
quote:
And what if I have two classes that have a void function and I want to assign one or the other depending on some condition? Do I then have to have a typedef for the function in both class A and class B?
Yes you''ll probably need two different typedefs, unless both classes inherits some base class and you can typedef a pointer to a method in that class.
quote:
2: Also, this solution seems to point to the general function for the class A. But what the function that you are pointing to does work with members of the specific class. Example:
class A
{public:
int x;
void functionA(){x++;}
};
Now say that you have 3 instances of class A like this:
A classA1;
A classA2;
A classA3;
When you set the function in class B equal to A::functionA, well, how would the compiler know which x to add? classA1.x, classA2.x, or classA3.x?
Basically you need an object to ''apply'' the method to. Look at my previous post for an example.