带单引号的整数文字? [英] Integer literal with single quotes?
本文介绍了带单引号的整数文字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
确切地赋给值的是什么?令我惊讶的是,它已经完全编译了.
What exactly as been assigned to value? I am surprised that this has compiled at all.
//g++ 7.4.0
#include <iostream>
int main()
{
auto value = 123'456'7;
std::cout << value << std::endl;
value += 1;
std::cout << value << std::endl;
}
输出:
1234567
1234568
推荐答案
自C ++ 14起,
来自 https://en.cppreference.com/w/cpp/language/integer_literal
可以在数字之间插入可选的单引号(')作为分隔符.它们会被编译器忽略.
Optional single quotes(') may be inserted between the digits as a separator. They are ignored by the compiler.
这篇关于带单引号的整数文字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文