Is this a pointer to a function pointer?

I know that void(*)() is a pointer to a function that returns nothing and takes no parameters, but what is void(**)()? Is it a pointer to a pointer to a function?

Also, could someone please explain to me what a signature VARIABLE is? Such as this:
1
2
//?
cout << typeid(void()).name() << endl;
void __cdecl(void)
What is a function signature when it is used such as return_type(param_type, ...) ?
Last edited on
Yes,
void(*)() is a pointer to function returning void
void(**)() is a pointer to pointer to function returning void
void() is a function returning void
These are types (just like int*, int**, and int). Like with any type, you can use typeid().name() to describe it.
Last edited on
Can I do this? I don't have a compiler to check.
1
2
3
4
5
6
7
8
9
typedef void() vf; //maybe typedef void vf(); ?

vf Func (AnotherFunc);
Func(); //calls it

void Call(vf &f)
{
    f();
}

Or am I interpreting your "just like [...] int" too literally?
Last edited on
Almost: can't initialize functions like variables, the rest is okay.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <iostream>

typedef void vf();

vf Func;

void Call(vf &f)
{
    f();
}

void Func() {
    std::cout << "sure\n";
}

int main()
{
    Func();
    Call(Func);
}


And yes, there are other limitations on function types: can't pass by value for example, which is why we have function objects.
Last edited on
Oh! So this whole time, function prototypes were actually...wow, I never knew. Thanks Cubbi!
Topic archived. No new replies allowed.