小编hac*_*eas的帖子

C++ 函数指针的计算结果为 1

我定义了一个指向函数的简单函数指针,当我尝试输出时,它的值为 1。幕后发生了什么?(我在mac上,用c++11 g++编译器编译)

#include <iostream>

int foo()
{
    return 5;
}


int main(int argc, char const *argv[])
{
    int (*fcptr)()  = foo;

    std::cout<< fcptr;
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

输出为1。

c++ pointers function-pointers function

3
推荐指数
1
解决办法
650
查看次数

标签 统计

c++ ×1

function ×1

function-pointers ×1

pointers ×1