Questions tagged «narrowing»

4
声明变量有两种类型:“ int char”
我是C ++初学者,正在阅读Bjarne Stroustrup的《编程:使用C ++的原理和实践》。 在关于3.9.2不安全转换的部分中,作者提到了 当初始值设定项是整数文字时,编译器可以检查实际值并接受不暗示变窄的值: int char b1 {1000}; // error: narrowing (assuming 8-bit chars) 我为这个宣言感到困惑。它使用两种类型(int和char)。我以前从未在Java和Swift中看到过这样的声明(我相对熟悉的两种语言)。这是拼写错误还是有效的C ++语法?
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.