开发者

Passing arguments by reference and address [duplicate]

This question already has answers here: Closed 12 years ago.

Possible Duplicate:

How to pass objects to functions in C++?

When should I be passing arguments by reference and when p开发者_JAVA百科assed by address?

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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜