How to Convert beween Stack and Heap Objects

前端 未结 7 810
暖寄归人
暖寄归人 2021-01-05 23:16

Example:

Class *_obj1;
Class *_obj2;

void doThis(Class *obj) {}

void create() {
    Class *obj1 = new Class();
    Class obj2;

    doThis(obj1);
    doThi         


        
7条回答
  •  星月不相逢
    2021-01-05 23:37

    the only way is to copy object.

    Change declaration to:

    Class _obj2;

    and assign:

    _obj2 = obj2;

提交回复
热议问题