c++ - 如何在 C++ 中为指针 'this' 赋值

标签 c++ this

在函数中,如何给this赋值?

最佳答案

您可以将对象 this 指向:

*this = XY;

但是你不能直接赋值this:

this = &XY;   // Error: Expression is not assignable

关于c++ - 如何在 C++ 中为指针 'this' 赋值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13476879/

相关文章:

php - 有没有办法在 PHP 匿名函数中不捕获 $this?

javascript - 为 forEach 方法中的数组项赋予值 'this' (javascript)

c++ - 在 async_resolve 上取消的操作

c++ - 在集合 C++ 中使用枚举时遇到问题

c++ - 添加文本到json C++

javascript - 在 Vanilla JavaScript 中的表的每个 <tr> 行中使用 AJAX `onKeyUp` 提交表单

javascript - 我可以更改 javascript "this"的上下文吗?

reactjs - useState 如何与 React 中的 eventListener 配合使用

c++ - 如何解决此问题以在 vector 中排序列表

c++ - atoi() 方法,char * cout