EngineersForge
Technical User
First of all, thank u all for the help so far! It is very quick and right on the money.
Now, I wish to use a function pointer as an event raised by a class type inherited by another. This is in a basic console, single thread for now as I am just testing the class hierarchy.
I have one public
void (*fpRaiseEvent) (void);
function pointer that is called also in a public fucntion. The main program defines the function to just print out some text. When I invoke the method from an instance of the class everything is ok. Now when I copy the class by another class object things go south some where in the copy constructor. This is my code:
sinc. func. pointers:
*fpReqSer = *rhs.fpReqSer; //complies but does not work
assign func. pointer:
void (*fpReqSer) (void) = rhs.fpReqSer; // complies but does not work
also complies:
fpReqSer = rhs.fpReqSer; //does not work
Their are many other combinations haha, all of which cause an access violation at run time. The more I stare at the pointer arithmetic, the less I know??? How does one assign the ‘being copied object’s’ pointer already assigned, to also let the coping object point to the same function?
Tanx
Now, I wish to use a function pointer as an event raised by a class type inherited by another. This is in a basic console, single thread for now as I am just testing the class hierarchy.
I have one public
void (*fpRaiseEvent) (void);
function pointer that is called also in a public fucntion. The main program defines the function to just print out some text. When I invoke the method from an instance of the class everything is ok. Now when I copy the class by another class object things go south some where in the copy constructor. This is my code:
sinc. func. pointers:
*fpReqSer = *rhs.fpReqSer; //complies but does not work
assign func. pointer:
void (*fpReqSer) (void) = rhs.fpReqSer; // complies but does not work
also complies:
fpReqSer = rhs.fpReqSer; //does not work
Their are many other combinations haha, all of which cause an access violation at run time. The more I stare at the pointer arithmetic, the less I know??? How does one assign the ‘being copied object’s’ pointer already assigned, to also let the coping object point to the same function?
Tanx