C++_函数返回指针

C++ 允许从函数返回指针。为了做到这点,必须声明一个返回指针的函数,如下所示:

int * myFunction()
{
    static int c[10];
    ...
    return c;
}

C++ 不支持在函数外返回局部变量的地址,除非定义局部变量为 static 变量。

猜你喜欢

转载自blog.csdn.net/qq_37140815/article/details/81152488