Tempory Variables, Reference Arguments, and const

  1. A C++ function with a const reference formal argument and a nonmatching actural argument mimics the traditional passing by value behavior, generating a temporary variable to hold the value and guaranteeing that the original data is unaltered.
  2. Temporary variables cause no harm and make the function more general in the sorts of arguments it can handle.
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章