Re: Returning a Struct from a Function
  Home FAQ Contact Sign in
comp.lang.c++ only
 
Advanced search
POPULAR GROUPS

more...

 Up
Re: Returning a Struct from a Function         

Group: comp.lang.c++ · Group Profile
Author: alex.j.k2
Date: May 11, 2008 11:18

On May 11, 2:02 pm, john gmail.com> wrote:
> alex.j...@gmail.com dixit:
>
>> Hello, newbie here.
>
>> I'd like to know if there is a way to return a structure from a
>> function, without creating any other intermediate variables. Also,
>> this should be done such that the function can still be declared as
>> inline.
>
> The usual way is to pass a reference to the struct (as a parameter) in
> which you want to put the return value (the same for vector, list, ...)

OK, that certainly works.

But is this the only way to do it?

What if I have a lot of code which returns a struct (or vector,
etc..) by creating an intermediate variable in the function; and I do
not want to modify all the occurrences of the function in the code,
only the function itself.

Can I eliminate the creation of the extra variable, while returning
the struct (but not as a parameter) ?

Also, thanks for the quick reply.

Alex
no comments
diggit! del.icio.us! reddit!

RELATED THREADS
SubjectArticles qty Group
Hypergeometric functions and beta functionssci.math ·
#43449 [NEW]: Segmentation Fault when calling PL/SQL-function wich returns ref cursormailing.www.phpdev ·