#include <iostream> using namespace std; class A { public: int i; int j; } int main() { const A* a = new A(); A* a1; a1 = a; }
这个是有道理的,能够这么做的话,const中内容就会被改变。
c++不允许指向常量的指针赋值给不指向常量的指针
原文:http://www.cnblogs.com/hong2016/p/6783333.html