这个问题已在这里得到解决.
建议的副本和当前给出的答案没有解决为什么首先给出的示例没有问题.主要是为什么没有推理:
" const int ** is a pointer to const int * 这与其他事情不同int*"
也适用于:
" const int * is a pointer to const int 这与其他事情不同int"
我从不同的角度接近它,希望得到另一种解释.
带有示例的代码.
#include <stdio.h>
void f_a (int const a){
/*
* Can't do:
* a = 3; //error: assignment of read-only parameter ‘a’
*
* Explanation: I can't change the value of a in the scope of the function due to the const
*/
printf("%d\n", a); …Run Code Online (Sandbox Code Playgroud)