Function Pointer Question

R

rdeml

I want a function that returns a function pointer to itself (or another
function of the same parameter set).


A function pointer to a function that takes nothing and returns nothing
is this:
typedef void (*FP)(void);
void Func(void);
FP fp;
fp = Func;
fp();

Now I want a function pointer to a function that returns a pointer to
the function:
typedef ???? (*FP)(void);
FP Func(void);
FP fp;
fp = Func;
fp = fp();

What do I put in the ?????
 
A

Andrew Koenig

I want a function that returns a function pointer to itself (or another
function of the same parameter set).

You can't do that directly. However, you can come close:

struct S {
S operator()(whatever);
};

Now an object of type S is a function object, and there is no problem in
having its operator() member return an object of type S when called.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,201
Messages
2,571,048
Members
47,651
Latest member
VeraPiw932

Latest Threads

Top