C ++文字中的定界符十进制和单位 [英] Delimiter tens and units in c++ literals

查看:77
本文介绍了C ++文字中的定界符十进制和单位的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Java中,我可以这样做:

In Java I can do:

int i = 1_200_200;

我该如何在c ++中执行相同的操作?我的意思是我应该用什么代替下划线?

How can I do something the same in c++? I mean what should I use instead of an underscore?

推荐答案

自C ++ 14起,您可以在

Since C++14 you can use single quotes (') for integer literal to improve the readability, e.g.

int i = 1'200'200;

可以在数字之间插入可选的单引号('),作为 分隔器.它们会被编译器忽略.

Optional single quotes(') may be inserted between the digits as a separator. They are ignored by the compiler.

这篇关于C ++文字中的定界符十进制和单位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆