0

I have the following code and to my surprise it works.

int func()
{
    cout << "aep" << endl;
    return 0;
}

int main() {
    int sp;
    int (*k)() = *****func;
    k();
    return 0;
}

Аs far as I know, functions pointer can be initialized in two ways

1.int (*k)() = func
2.int (*k)() = &func

But what happens in case of ?

int (*k)() = *func or int (*k)() = ***func ?

And one more thing, cout << func gets as a result 1, why ?

  • Here is a duplicate for the "one more thing" http://stackoverflow.com/questions/2064692/how-to-print-function-pointers-with-cout – eerorika Sep 22 '15 at 08:19
  • @πάνταῥεῖ: It [works](http://ideone.com/AAq6Gj) once you fix missing `std::`. – Jarod42 Sep 22 '15 at 08:21

0 Answers0