class object {
public
object(parameters);
...
const object& method1(parameters) const;
object& method2(parameters) const;
private
members;
}
the "method1" and "method2" implementations are:
const object& object::method1(parameters) const {
...
object* _obj = new object;
...
return *_obj;
}
object& object::method2(parameters) const {
...
object* _obj = new object;
...
return *_obj;
}
the "object" doesn't have copy constructor. What is the return of the two members? does they return the allocated object ? or does they return a copy of that?
I would like to avoid wasting memory
migth you be more specific writing down an example?
which criteria should i use?
I thought to a container for every allocated addresses in this way, so i can cancel them later, when they are not used.
Is this the rigth way to do this, or am i missing something?