zoukankan      html  css  js  c++  java
  • passing parameters by value is inefficient when the parameters represent large blocks of data

    Computer Science An Overview _J. Glenn Brookshear _11th Edition_C

    Note that passing parameters by value protects the data in the calling unit from being mistakenly altered by a poorly designed procedure. For example, if the calling unit passed an employee’s name to a procedure, it might not want the procedure to change that name.

    Unfortunately, passing parameters by value is inefficient when the parameters represent large blocks of data. A more efficient technique is to give the procedure direct access to the actual parameters by telling it the addresses of the actual parameters in the calling program unit. In this case we say that the parameters are passed by reference. Note that passing parameters by reference allows the procedure to modify the data residing in the calling environment. Such an approach would be desirable in the case of a procedure for sorting a list.

    The task of transferring data between actual and formal parameters is handled in a variety of ways by different programming languages. In some languages a duplicate of the data represented by the actual parameters is produced and given to the procedure. Using this approach, any alterations to the data made by the procedure are reflected only in the duplicate—the data in the calling program unit are never changed. We often say that such parameters are passed by value.

    a duplicate of the data // 副本

  • 相关阅读:
    计划任务和压缩归档
    libevent 源码学习三 —— 基本使用场景和事件流程
    libevent 源码学习二 —— reactor 模式
    libevent 库源码学习
    手动配置固定IP参数vim vim
    软件相关
    写xhttpd服务器时 遇到segmentation fault
    c与c++中输出字符指针和字符串指针的问题
    char * argv[] ,string简析
    传入参数与传出参数
  • 原文地址:https://www.cnblogs.com/rsapaper/p/6046509.html
Copyright © 2011-2022 走看看