We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
运算表达式产生的临时变量、 原始字面量、Lambda 表达式都属于纯右值。
原始字面量并不一定是右值,比如 字符字面量,字符字面量可以被取地址,是一个左值。
参见:https://en.cppreference.com/w/cpp/language/value_category
The text was updated successfully, but these errors were encountered:
更加糟糕的是,在类中的字符字面量是一个右值:
class Parent{ const char* s = &"hello"; // 此时 "hello" 为右值,无法取地址,无法通过编译 } int main(){ &“hello”; // 此时"hello"为左值,可以去地址,可以通过编译 }
Sorry, something went wrong.
PR welcome
book: fix incorrect string literal (#102) and a typo (#103)
3abc907
Successfully merging a pull request may close this issue.
实际描述
原文表意不准确:
原始字面量并不一定是右值,比如 字符字面量,字符字面量可以被取地址,是一个左值。
参见:https://en.cppreference.com/w/cpp/language/value_category
The text was updated successfully, but these errors were encountered: