[C++] c++ 返回引用给一个不存在的对象 →→→→→进入此内容的聊天室

来自 , 2020-02-14, 写在 C++, 查看 106 次.
URL http://www.code666.cn/view/069654d5
  1. // LISTING 9.12 - Returning a Reference to a Nonexistent Object
  2. #include <iostream>
  3.  
  4. int& GetInt();
  5.  
  6. int main() {
  7.         int & rInt = GetInt();
  8.         std::cout << "rInt = " << rInt << std::endl;
  9.  
  10.         return 0;
  11. }
  12.  
  13. int & GetInt() {
  14.         int nLocalInt = 25;
  15.  
  16.         return nLocalInt;
  17. }
  18.  

回复 "c++ 返回引用给一个不存在的对象"

这儿你可以回复上面这条便签

captcha