为什么函数可以改变 `const char * & value`?

Why function can change `const char * & value`?

这是一个以const char * &为参数的函数示例。

#include <iostream>
using namespace std;

char test[] = "Test";

void func(const char * & str)
{
    str = &test[0];
}

int main() {
    const char * mytest;

    func(mytest);

    cout << mytest << endl;

    return 0;
}

为什么这行得通? (http://ideone.com/7NwmYd)

这里的const是什么意思?为什么func()可以改变str赋予这个函数?

更新。菜鸟问题,请不要删

cost 指的是紧靠其左侧的声明部分,除非在 const 是第一个的特殊情况下,在这种情况下紧靠其右侧:

const char * &  // the char is const, the * is not
char const * &  // the char is const, the * is not
char * const &  // the * is const, the char is not
char const * const &  // the char and * are both const

您有一个指向 const char 的非 const 指针并修改了指针(不是 char),因此编译器没有什么可抱怨的。