我无法解释自己以下代码:关于C++中const指针的问题?
double d = 100;
double const d1 = 30;
double* const p = &d; // Line 1
double* const p1 = &d1; // Line 2
在上面的代码,Line 1
是好的,但Line 2
产生错误:
"error C2440: 'initializing' : cannot convert from 'const double *__w64 ' to 'double *const '"
谁能详细说说吗?我正在使用VS C++ 2005,在Win XP SP3上运行)
请阅读:http://www.parashift.com/c++-faq-lite/const-correctness.html#faq-18.5 –