0

Possible Duplicate:
How to pass objects to functions in C++?

When should I be passing arguments by reference and when passed by address?

I mean Except the case of pass by const reference, is there any difference between the two.

Community
  • 1
  • 1
ashmish2
  • 2,885
  • 8
  • 40
  • 54
  • 1
    (more than) possible duplicate: [C++ Objects: When should I use pointer or reference](http://stackoverflow.com/questions/4288030/c-objects-when-should-i-use-pointer-or-reference/4288087#4288087) – suszterpatt Dec 10 '10 at 10:24
  • check this answer at yahoo answers [http://answers.yahoo.com/question/index?qid=1006051001452](http://answers.yahoo.com/question/index?qid=1006051001452) –  Dec 10 '10 at 10:21

1 Answers1

0

I personally pass by pointer (address) when the pointer may be null, and pass by reference when it can't be null.

There are plenty of other considerations (const/non-const, smart/weak pointers etc) but I think this is a good guideline and answers your question well.

Ben Hymers
  • 25,586
  • 16
  • 59
  • 84