下面的代码不编译C++非常量为const铸造编译错误
void aaa(const int **a) {
}
int *a[] = {new int[2]};
aaa(a);
我 “不能从转换参数1 'INT [1]' 至“const int的*” 在VS2010和在GCC类似的错误
当我改变我的声明:
int const *a[] = {new int[2]};
或
const int *a[] = {new int[2]};
它编译,但我不明白为什么它不接受非const的变量声明
也许'AAA(PA)'应该是' aaa(pa)' – bitstore 2012-02-24 15:33:47
@tinybit或者它的声明应该是'int * pa;',调用后的使用应该是'* pa = 0;'。我将编辑修复我的答案中的代码。感谢您发现这一点。 – 2012-02-24 16:44:36