【发布时间】:2013-12-03 17:05:39
【问题描述】:
class scope{
//...
scope* parent;
//...
public:
//...
void leavescope();
//...
};
void scope::leavescope(){
this = this->parent; // complains about this line
}
我正在尝试实现作用域,但在离开作用域并返回外层作用域时遇到了麻烦。
【问题讨论】:
-
编译器是对的,不能赋值
this。要解决此问题,您需要更好地描述您的用例。您是否正在创建许多scope对象?好像是这样的。通常你只是让一个超出范围,这会破坏它。
标签: c++ class scope variable-assignment lvalue