Change 'this' pointer of an object to point different object

后端 未结 6 1378
花落未央
花落未央 2021-02-07 08:01
class C{
   //methods and properties
}

void C::some_method(C* b){
    delete this;
    this = b;     
}

This gives me follwing error when compiling:

6条回答
  •  日久生厌
    2021-02-07 08:53

    You cannot change what this points to. I would also not know why you'd want to do this.

提交回复
热议问题