久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

錯誤:從“int"類型的右值初始化“int&

error: invalid initialization of non-const reference of type ‘intamp;’ from an rvalue of type ‘int’(錯誤:從“int類型的右值初始化“intamp;類型的非常量引用無效)
本文介紹了錯誤:從“int"類型的右值初始化“int&"類型的非常量引用無效的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

錯誤的形式:

int &z = 12;

正確形式:

int y;
int &r = y;

問題:
為什么第一個代碼是錯誤的?標題中錯誤的含義"是什么?

推薦答案

C++03 3.10/1 說:每個表達式要么是左值,要么是右值."重要的是要記住,左值與右值是表達式的屬性,而不是對象的屬性.

C++03 3.10/1 says: "Every expression is either an lvalue or an rvalue." It's important to remember that lvalueness versus rvalueness is a property of expressions, not of objects.

左值命名對象超出單個表達式.例如, obj*ptrptr[index]++x 都是左值.

Lvalues name objects that persist beyond a single expression. For example, obj , *ptr , ptr[index] , and ++x are all lvalues.

右值是在它們所在的完整表達式的末尾(在分號處")消失的臨時變量.例如, 1729x + ystd::string("meow")x++ 是所有右值.

Rvalues are temporaries that evaporate at the end of the full-expression in which they live ("at the semicolon"). For example, 1729 , x + y , std::string("meow") , and x++ are all rvalues.

address-of 運算符要求其操作數應為左值".如果我們可以取一個表達式的地址,那么這個表達式就是一個左值,否則就是一個右值.

The address-of operator requires that its "operand shall be an lvalue". if we could take the address of one expression, the expression is an lvalue, otherwise it's an rvalue.

 &obj; //  valid
 &12;  //invalid

這篇關于錯誤:從“int"類型的右值初始化“int&"類型的非常量引用無效的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Difference between std::reference_wrapper and simple pointer?(std::reference_wrapper 和簡單指針的區別?)
Difference between const. pointer and reference?(常量之間的區別.指針和引用?)
How to access the contents of a vector from a pointer to the vector in C++?(c++ - 如何從指向向量的指針訪問向量的內容?)
Meaning of *amp; and **amp; in C++(*amp; 的含義和**amp;在 C++ 中)
Why can#39;t I do polymorphism with normal variables?(為什么我不能對普通變量進行多態?)
Dereferencing deleted pointers always result in an Access Violation?(取消引用已刪除的指針總是會導致訪問沖突?)
主站蜘蛛池模板: 99综合网 | 国产一区二区在线免费观看 | av影音在线 | 二区三区视频 | 欧美成人影院在线 | 91网在线播放 | 午夜精品视频一区 | 日韩一区二区不卡 | 久久99久久98精品免观看软件 | 范冰冰一级做a爰片久久毛片 | 巨大荫蒂视频欧美另类大 | 国产日韩欧美精品 | 精品精品 | 欧美日韩视频在线第一区 | 久久99网 | 久久99精品久久久久 | 在线观看中文字幕亚洲 | 成人三级在线观看 | 在线观看国产wwwa级羞羞视频 | 国产精品亚洲视频 | 中文字幕在线免费视频 | 欧美精品首页 | av一级久久 | 中文二区| 91婷婷韩国欧美一区二区 | 国产成人精品久久二区二区91 | 欧美高清视频一区 | 精品国产乱码一区二区三区 | 国产a视频| 黑人久久久 | 国产小网站 | 欧美日韩在线精品 | 亚洲精品永久免费 | 亚洲高清在线视频 | www.久久国产精品 | 天天干成人网 | 91视频在线| 国产精品高清在线 | 欧美一级片在线 | 欧美国产亚洲一区二区 | 亚洲综合区 |