Thread: passing by address vs passing by reference

  1. #16
    Programming Sex-God Polymorphic OOP's Avatar
    Join Date
    Nov 2002
    Posts
    1,078
    The phrase "pass by reference" was used in C even before C++ to refer to passing data via a pointer to the location of the object.

    Passing a pointer by value can be looked at as passing a value by reference. Passing by reference just means that you aren't copying the data that you will be directly working with, you are dealing with it indirectly.

    The concept of passing by refernce is the same in both C and C++, it's just that things become more confusing in terms of the because in C++ there are more ways of doing it and because there actually is a such thing as a "reference."
    Last edited by Polymorphic OOP; 01-09-2003 at 01:09 AM.

  2. #17
    Blank
    Join Date
    Aug 2001
    Posts
    1,034
    In c, they needed a way to simulate a pascal function such
    as
    Code:
    procedure swap(var a : integer, var b : integer)
    begin
         t : integer;
     
         t = a;
         a = b;
         b = t;
    end
    It's been a long time since I programed in pascal but
    the var modifier makes the variables pass by referance.
    The usual definition of pass by referance is that the caller
    can modify the variable not just what the variable points to.
    But this leaves out c++ const pass by referance.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. Strange/false errors
    By Ganoosh in forum Windows Programming
    Replies: 8
    Last Post: 10-20-2005, 04:54 PM
  3. Textbox
    By maxorator in forum Windows Programming
    Replies: 20
    Last Post: 09-25-2005, 10:04 AM
  4. c++ linking problem for x11
    By kron in forum Linux Programming
    Replies: 1
    Last Post: 11-19-2004, 10:18 AM
  5. Im so lost at . .
    By hermit in forum C Programming
    Replies: 18
    Last Post: 05-15-2002, 01:26 AM