Argument passing

This is a discussion on Argument passing within the C++ Programming forums, part of the General Programming Boards category; This may be a bit of a newbie question but here goes anyway. I'm writing a very cpu intensive program ...

  1. #1
    Registered User
    Join Date
    Apr 2003
    Posts
    2

    Argument passing

    This may be a bit of a newbie question but here goes anyway.

    I'm writing a very cpu intensive program and therefore want to optimize as much as possible. I just wanted to know if passing objects by pointer is faster than passing them by reference. It would seem to me that both methods should be about the same, but I would like the opinion of someone more knowledgeable than myself. Thanks.

  2. #2
    Just because ygfperson's Avatar
    Join Date
    Jan 2002
    Posts
    2,493
    I e-mailed bjarne stroustrup (creator of c++) about this a year ago, and he said there's no difference.
    http://www.flashdaddee.com/forums/sh...ght=stroustrup
    A quote from it: ('>' is me, he responds)
    >this makes a potential scanf in c++ more elegant to use, and to create. my
    >point is that this seemingly easy to implement idea is neglected in C but
    >added in C++ on the basis of its relationship to the equivalent assembly
    >language commands.
    >
    >what do you think? thank you for your time.

    Remember that access through a reference will involve exactly the same machine
    operations as access through a pointer for equivalent uses.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 04-11-2008, 03:42 AM
  2. function passing argument..array ?
    By jochen in forum C Programming
    Replies: 2
    Last Post: 09-30-2007, 12:53 PM
  3. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 03:39 PM
  4. Passing function as an argument.
    By hyaku_ in forum C Programming
    Replies: 1
    Last Post: 12-11-2005, 04:43 AM
  5. problem passing an option as command line argument
    By papous in forum C Programming
    Replies: 3
    Last Post: 11-22-2001, 06:12 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21