A
Alex
Hi everyone,
I have a question that implies thinking about some design issues with C
++.
I have a method like this:
class C {
....
public:
void get_something(std::vector<Something*>& results);
}
It returns a vector of objects that should be created (or filled in
with data) by the class C.
The problem is, if the Something objects are created inside
get_something, I will have to delete them later outside the function,
and I must avoid that for several reasons.
I don't know how many objects will be in the vector, so I can't create
the objects in advance and pass a vector of references to be filled in
by the function.
What is your advice for this kind of situations?
Thanks.
I have a question that implies thinking about some design issues with C
++.
I have a method like this:
class C {
....
public:
void get_something(std::vector<Something*>& results);
}
It returns a vector of objects that should be created (or filled in
with data) by the class C.
The problem is, if the Something objects are created inside
get_something, I will have to delete them later outside the function,
and I must avoid that for several reasons.
I don't know how many objects will be in the vector, so I can't create
the objects in advance and pass a vector of references to be filled in
by the function.
What is your advice for this kind of situations?
Thanks.