...。除非你指定其他方式,函数参数会用实际参数值的拷贝进行初始化,函数调用者会获得函数返回值的一份拷贝。这些拷贝由对象的拷贝构造函数生成。这使得按值传递(pass-by-value)变成一项昂贵的操作。举个例子,考虑下面的类继承体系(Item 7): 1 class Person {
基于126个网页-相关网页
pass by value 传值 ; 值传递
However, you must be aware that these alternatives change the semantics of the interaction from pass-by-value to pass-by-reference.
然而,您必须注意到这些可供选择的方案会将交互方法从按值传递(pass - by - value)改变为按引用传递(pass - by - reference)。
If you need runtime polymorphism, you must not use pass-by-value.
如果你需要运行时多态,你不能使用按值传递。
If the EJB client and EJB modules are mapped to different application server instances (often referred to as split-tier), then the EJB modules must be invoked remotely using pass by value semantics.
如果EJB客户机和EJB模块被映射到不同的应用服务器实例(通常表示为split - tier),则必须使用通过值传递的语义来远程调用EJB模块。
应用推荐