c++不允许指向常量的指针赋值给不指向常量的指针

#include <iostream>
using namespace std;

class A
{
public:
	int i;
	int j;


}

int main()
{
	
const A* a = new A();
A* a1;
a1 = a;


}

  这个是有道理的,能够这么做的话,const中内容就会被改变。

posted @ 2017-04-28 21:14  每天一点积累  阅读(404)  评论(0编辑  收藏  举报