Click here to Skip to main content
15,894,646 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Advanced Function Pointer? Pin
Stefan Pedersen7-Jan-03 1:55
Stefan Pedersen7-Jan-03 1:55 
GeneralRe: Advanced Function Pointer? Pin
Aidman7-Jan-03 3:28
Aidman7-Jan-03 3:28 
GeneralRe: Advanced Function Pointer? Pin
Stefan Pedersen7-Jan-03 3:34
Stefan Pedersen7-Jan-03 3:34 
GeneralRe: Advanced Function Pointer? Pin
Todd Smith7-Jan-03 5:46
Todd Smith7-Jan-03 5:46 
GeneralRe: Advanced Function Pointer? Pin
Aidman7-Jan-03 6:37
Aidman7-Jan-03 6:37 
GeneralRe: Advanced Function Pointer? Pin
Chris Richardson7-Jan-03 7:38
Chris Richardson7-Jan-03 7:38 
GeneralRe: Advanced Function Pointer? Pin
Aidman7-Jan-03 10:50
Aidman7-Jan-03 10:50 
GeneralFunction Pointers in OOP Pin
tilli again6-Jan-03 11:11
susstilli again6-Jan-03 11:11 
Hey everyone!

Okay, I have the following code:

typedef int (*funcP) (int v1, int v2);

struct pStruc
{
funcP callback;
};

struct pStruc *callbacks;

int someFunc (int v1, int v2)
{
return v1 + v2;
}

int anotherFunc (int v1, int v2)
{
return v1 - v2;
}

struct pStruc *assignFuncs ()
{
return (struct pStruc []) {&someFunc, &anotherFunc};
}

void main ()
{
callbacks = assignFuncs ();
cout << callbacks->callback (10, 20);
}

Output will be 30.

You should get the idea: I have an array of function pointers, and I need to call the stored functions. Works so far. Now, what will I have to do if assignFuncs as well as the two refered functions are members of some class? I'd like to have it working in a very flexible way, without any hardcoded class name! Any idea?

tilli
GeneralRe: Function Pointers in OOP Pin
Alvaro Mendez6-Jan-03 11:38
Alvaro Mendez6-Jan-03 11:38 
GeneralRe: Function Pointers in OOP Pin
William E. Kempf6-Jan-03 12:03
William E. Kempf6-Jan-03 12:03 
GeneralRe: Function Pointers in OOP Pin
valikac6-Jan-03 16:07
valikac6-Jan-03 16:07 
GeneralRe: Function Pointers in OOP Pin
tilli again7-Jan-03 8:43
susstilli again7-Jan-03 8:43 
GeneralRe: Function Pointers in OOP Pin
tilli again8-Jan-03 8:18
susstilli again8-Jan-03 8:18 
QuestionTree Control Check Boxes... ??? Pin
work_to_live6-Jan-03 9:31
work_to_live6-Jan-03 9:31 
AnswerRe: Tree Control Check Boxes... ??? Pin
work_to_live6-Jan-03 9:51
work_to_live6-Jan-03 9:51 
QuestionSynchronization.. do I need? Pin
Subrahmanyam6-Jan-03 9:15
Subrahmanyam6-Jan-03 9:15 
AnswerRe: Synchronization.. do I need? Pin
Tim Smith6-Jan-03 10:17
Tim Smith6-Jan-03 10:17 
AnswerRe: Synchronization.. do I need? Pin
Chris Losinger6-Jan-03 10:59
professionalChris Losinger6-Jan-03 10:59 
QuestionDebugging Mutexes? Pin
clintsinger6-Jan-03 8:09
clintsinger6-Jan-03 8:09 
AnswerRe: Debugging Mutexes? Pin
Tim Smith6-Jan-03 8:39
Tim Smith6-Jan-03 8:39 
GeneralRe: Debugging Mutexes? Pin
clintsinger6-Jan-03 8:47
clintsinger6-Jan-03 8:47 
GeneralRe: Debugging Mutexes? Pin
Tim Smith6-Jan-03 10:16
Tim Smith6-Jan-03 10:16 
GeneralRe: Debugging Mutexes? Pin
clintsinger9-Jan-03 7:42
clintsinger9-Jan-03 7:42 
GeneralLocalization issue Pin
Nish Nishant6-Jan-03 7:30
sitebuilderNish Nishant6-Jan-03 7:30 
GeneralRe: Localization issue Pin
Maximilien6-Jan-03 7:34
Maximilien6-Jan-03 7:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.