BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Passing structure to a fucntion by Reference vs by Value

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Native API)
View previous topic :: View next topic  
Author Message
Renald Yazmir
Guest





PostPosted: Tue Jul 25, 2006 12:59 am    Post subject: Passing structure to a fucntion by Reference vs by Value Reply with quote



Hello,
Are there any problems passing structure by value to a function?
Can it be a problem for multiple recursive calls?
My structure contains 10 doubles, 1 short and char arr[6].
Any memory restrictions?

Thank you in advance
Rony
Back to top
Dennis Jones
Guest





PostPosted: Tue Jul 25, 2006 1:56 am    Post subject: Re: Passing structure to a fucntion by Reference vs by Value Reply with quote



"Renald Yazmir" <renald (AT) partmaker (DOT) com> wrote in message
news:44c5268d (AT) newsgroups (DOT) borland.com...
Quote:
Hello,
Are there any problems passing structure by value to a function?
Can it be a problem for multiple recursive calls?
My structure contains 10 doubles, 1 short and char arr[6].
Any memory restrictions?

I guess I'd want to know why you would prefer to avoid passing by reference
in the first place. Passing by reference (or by pointer) would almost
certainly be more efficient, not to mention less likely to have an impact on
recursive calls. However, having said that, since you're only talking about
roughly 90 bytes, you're probably not going to run into any trouble anyway.

- Dennis
Back to top
Ed Mulroy
Guest





PostPosted: Tue Jul 25, 2006 2:35 am    Post subject: Re: Passing structure to a fucntion by Reference vs by Value Reply with quote



The program slows down by the amount of time it takes make a copy of the
structure on the stack.

If recursion is used then each time you recurse it again uses one
structure-sized hunk of stack and delays for however long the copy takes for
each iteration.

Using a reference is normally a better way, especially if recursion is
involved.

.. Ed

Quote:
Renald Yazmir wrote in message
news:44c5268d (AT) newsgroups (DOT) borland.com...

Are there any problems passing structure by value to a function?
Can it be a problem for multiple recursive calls?
My structure contains 10 doubles, 1 short and char arr[6].
Any memory restrictions?
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Native API) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.