如何在C+中“返回一个对象”?
public Thing calculateThing() { Thing thing = new Thing(); // do calculations and modify thing return thing;}
void calculateThing(Thing& thing) { // do calculations and modify thing}
Thing thing;calculateThing(thing);
Thing* calculateThing() { Thing* thing(new Thing()); // do calculations and modify thing return thing;}
Thing* thing = calculateThing();delete thing;
delete thing;
翻过高山走不出你
料青山看我应如是
当年话下
相关分类