我试图对一个真正const的类进行const操作 - 它不会更改类指向的数据.
例如:
class Node{
public:
int val;
};
class V{
public:
Node * node; //what is the change that is needed here?
void const_action()const{
node->val=5; //error wanted here
}
void action(){
node->val=5; //error is not wanted here
}
};
Run Code Online (Sandbox Code Playgroud)