
Function Pointer Problem--Please Assist
I have been having problems trying to resolve passing a pointer function
in C++.
It appears that my program elicits errors based on
the following lines of code:
in a separate class's .c file:
//rgb_t rgb = solid->tex().givrgb(); //Case 1
//rgb_t rgb = solid->tex->givrgb(); //Case 2
//rgb_t rgb = solid->tex(givrgb()); //Case 3
rgb_t rgb = rgb_t(15,15,15);
Where:
rgb_t is a type from class rgb,
solid is of a class presolid.
tex is def'd by:
public:
texture_t(*tex)();
and givrgb() is a public member function
The only line that actually worked was the hard-coded (15,15,15) line.
Case 1 compiled and linked, but resulted in a run-time "Illegal
Instruction" error. Cases 2 and 3 did not compile correctly.
Any ideas? Btw, I also tried ->(*tex)().givrgb(); but that
did not compile either. Am I calling this pointe function correctly?
Thanks in advance...
Perry ...