Thread: What is more useful in functions?

  1. #1
    Unregistered
    Guest

    Question What is more useful in functions?

    What is more practical, call by value, or call by reference for most computation projects? Thanks

  2. #2
    Registered User
    Join Date
    Sep 2001
    Posts
    412
    Are you asking whether you should pass arguments by reference, or value?

    It all depends on the application, and the type of parameter. A good rule of thumb is:

    * If you are passing a parameter which will be changed/set by the function, pass by reference.
    * If you are passing a parameter whose size is considerably larger than 4 bytes (the size of the address) pass by reference.
    * If the size of the parameter is small, and the parameter does not need modification, pass by value.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Void Functions Help
    By bethanne41 in forum C++ Programming
    Replies: 1
    Last Post: 05-09-2005, 05:30 PM
  2. Functions and Classes - What did I do wrong?
    By redmage in forum C++ Programming
    Replies: 5
    Last Post: 04-11-2005, 11:50 AM
  3. calling functions within functions
    By edd1986 in forum C Programming
    Replies: 3
    Last Post: 03-29-2005, 03:35 AM
  4. Factory Functions HOWTO
    By GuardianDevil in forum Windows Programming
    Replies: 1
    Last Post: 05-01-2004, 01:41 PM
  5. Shell functions on Win XP
    By geek@02 in forum Windows Programming
    Replies: 6
    Last Post: 04-19-2004, 05:39 AM