a pointer to a function, which can be stored in a variable allows a run-time choice of which function to run

learn more… | top users | synonyms (1)

0
votes
4answers
50 views

Using a function pointer

I have a function in C that is crashing my code and I'm having a hard time figuring out what is going on. I have a function that looks like this: #define cond int void Enqueue(cond (*cond_func)()); ...
5
votes
3answers
105 views

Function pointer vs Function reference

In the code below, function-pointer and what i considered as "function-reference" seems to have identical semantics: #include <iostream> using std::cout; void func(int a) { cout << ...
2
votes
0answers
45 views

Strange behaviour, initialize a function pointer with an int?

Accidentally, I found this code compiles on VS2012. typedef void (*func)(); func f = func(12); f is initialized with an integer 12 as its address. as far as I know, cast from integer to a function ...
0
votes
3answers
22 views

How to pass a bidimensional array as an argument to a function?

I'm trying to make a function that displays a certain matrix; That's what I've tried to do: void print(int n,int a[n][n]) { for(int i=1;i<=n;i++) { for(int ...
0
votes
2answers
29 views

C++ map of “events” and member function pointers

I've managed to write a template class to work like a callback, learned from the accepted answer of this question How to define a general member function pointer. I wish to have a map of string keys ...
0
votes
1answer
48 views

C++ Implementing a Button with member-function callback

I am trying to implement a simple GUI component in C++. The 'Button' class exists in a library that is completely de-coupled from the main program. I want to be able to pass a function-pointer to a ...
2
votes
3answers
35 views

Passing states of StateMachine as parameter to a function pointer C++ OOP

I'm fairly new to the concept of function pointer in C++, so I don't know how to write my question properly. Please bear with me. Basically, what I'm trying to do is to create a Button object whose ...
20
votes
2answers
363 views

Are two function pointers to the same function always equal?

Does the C++ standard guarantee that two pointers to a function always compare equal? I understand that this will normally be true for non-inline functions. But if there is an inline function and a ...
1
vote
1answer
26 views

How to assign dlsym()'s return value to function type?

My problem is as follows: I have a structure containing function pointers like this: typedef void (CALLING_COVNENTION * functionType_t) (/*...*/); typedef struct myFuncpointerStruc_s { /*...*/ ...
0
votes
1answer
54 views

Passing getter/setter as a method reference

I have a bunch of entries like these two: if (update) { if (activity.getName() == null) { logger.debug(" Setting name on " + id); } else ...
3
votes
2answers
32 views

boost::bind thread for pointer to function with argument

I have a function foo(myclass* ob) and I am trying to create a consumer thread using consumer_thread(boost::bind(&foo)(&ob)) The code does not compile which I believe is due to my ...
3
votes
5answers
51 views

How can I pass a module's function as a reference to another module in Perl?

How can I pass a reference to a module's function as parameter in a function call of another module? I tried the following (simple example): This is the module that has a function (process_staff) that ...
1
vote
1answer
29 views

error: expected primary-expression before ')' when passing function-pointer to a function

Following is the function that takes function prototype as an argument: void callAdded(void (*unitAdded)(rates)); When I do: callAdded((&ConverterProxy::unitAdded)(rates)); ...
0
votes
1answer
56 views

Function declarations with * in front and void returning values? [duplicate]

So, I'm reading Beej's Guide to Network Programming, and he uses this function: void *get_in_addr(struct sockaddr *sa) { if (sa->sa_family == AF_INET) { return &(((struct ...
0
votes
1answer
42 views

Currying a generic method / function without loosing generic parameters

I just realized that my generic method: def method[A](list: List[A]): A = { ... } will result in a non-generic function type val methodFun = method _ -> methodFun : (scala.List[Nothing]) => ...

15 30 50 per page