By Reference or By Pointer in Method Arguments
来源:互联网 发布:sjf调度算法例题 编辑:程序博客网 时间:2024/06/06 11:32
- To allow you to alter a data object in the calling function
- To speed up a program by passing a reference instead of an entire data object
No modify the data,
-
If the data object is small, such as a built-in data type or a small structure, pass it by value.
-
If the data object is an array, use a pointer because that's your only choice. Make the pointer a pointer to const.
-
If the data object is a good-sized structure, use a const pointer or a const reference to increase program efficiency. You save the time and space needed to copy a structure or a class design. Make the pointer or reference const.
-
If the data object is a class object, use a const reference. The semantics of class design often require using a reference, which is the main reason why C++ added this feature. Thus, the standard way to pass class object arguments is by reference.
Does modify the data,
-
If the data object is a built-in data type, use a pointer.
-
If the data object is an array, use your only choice, a pointer.
-
If the data object is a structure, use a reference or a pointer.
-
If the data object is a class object, use a reference.
- By Reference or By Pointer in Method Arguments
- passing arguments by reference
- Parameter passing in Java - by reference or by value?
- Pass By Value or Pass By Reference in java
- By value? Or by reference?
- Call by value Call by pointer Call by reference
- java中的 by value or by reference
- java中的 by value or by reference
- JavaScript: Passing by Value or by Reference
- call by value or reference ?
- call by value or reference
- call by value or reference
- call by value or reference
- call by value or reference
- call by value ;call by address/reference ;call by name;call by pointer
- Call by reference in R
- Java: pass by value or reference?
- Passing by reference or by value? it is a question
- weblogic-application.xml Deployment Descriptor
- VPN with SSH
- Linux以及各大发行版介绍
- 不规则窗体和控件的创建
- epoll相关资料整理
- By Reference or By Pointer in Method Arguments
- Multi Data Sources
- UVa Problem Solution: 10252 - Common Permutation
- 网站制作代码优化的小技巧
- 英语学习
- js控制上传文件的文本框,不能输入内容,贴粘,及输入法切换.
- VC 6.0 写完的程序程编译链接通过后,点运行的时候出现one or more files out of date or not exist
- 也许我真是个火星人
- HttpUtility.Encode与Server.Encode