|
From: matheus r. <mfr...@gm...> - 2007-09-27 15:25:22
|
Uour code is very confusing, its not clear to me what youre doing.
Anyway, this will cause a memory leak, since youll lose the pointer to
copia and keep only the reference to it. Either return the allocated
pointer or pass the vector as an argument to the function.
2007/9/27, Laura Lozano <lau...@gm...>:
> Hello,
>
> Is this the best way to return a vector of Pointers that is an atribute of a
> class?? I don't return the vector directly to avoid delete externaly the
> pointers Resultado*, because is an attribute of the class.
>
> vector<Resultado*>& ValidacionCruzadaEval::getResultados(){
> vector<Resultado*>::const_iterator it;
> vector<Resultado*>* copia=new vector<Resultado*>;
>
> copia->reserve(resultados.size());
>
> for(it=resultados.begin();it!=resultados.end();it++){
>
> copia->push_back(new Resultado(**it));
>
> }
> return *copia;
>
> }
>
>
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2005.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE:
> http://www23.brinkster.com/noicys/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
>
|