Thread: Argument passing

  1. #1
    Registered User
    Join Date
    Apr 2003

    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
    I e-mailed bjarne stroustrup (creator of c++) about this a year ago, and he said there's no difference.
    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, 02:42 AM
  2. function passing argument..array ?
    By jochen in forum C Programming
    Replies: 2
    Last Post: 09-30-2007, 11:53 AM
  3. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02: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