在我读过的所有C++风格指南中,我从未看到过任何关于数字字面图的信息(即3.14f
、0L
等)。
<<>问题>
是否有任何风格的指南可以说明关于使用该方法的会谈,或是否有一般性公约?
我偶尔在制图中见到<代码>f。 方案拟订领域的使用是否有任何趋势?
在我读过的所有C++风格指南中,我从未看到过任何关于数字字面图的信息(即3.14f
、0L
等)。
<<>问题>
是否有任何风格的指南可以说明关于使用该方法的会谈,或是否有一般性公约?
我偶尔在制图中见到<代码>f。 方案拟订领域的使用是否有任何趋势?
我没有发现的一般风格指南。 我用英文大写字母附加数字编号。 我也用适当的颜色来形容整体。
我假定你知道这些图象意味着什么:3.14F
是一个float
,字面上是12.345,字面是两字面,6.66L是一字面长。
ger:U
。 <代码>U和之间的次序 L
don t matter,但我总是带UL
。 例如,我宣布这些变量为<代码>。
如果你将一种类型的变数定为另一种类型的字面,或者为另一种类型的功能论证提供一种类型的数字字面。 采用适当的颜色避免了这种情况,并且与静态预测一样有用,有助于挑出。 始终如一地使用数字字面图是好的风格,避免了数字的意外。
People differ on whether lower or upper case is best. Pick a style that looks good to you and be consistent.
我知道的唯一既定公约(有些已经确定,有的)是永远使用<代码>L而不是l<>/code>,以避免在<1>
上被误入。 除此之外,它还非常需要使用你所需要的东西。
还指出,C++11允许用户界定的字面与用户界定的颜色。
The CERT C Coding Standard recommends to use uppercase letters:
DCL16-C. Use "L," not "l," to indicate a long value
下几封信(1)很容易与数字1(一)混为一谈。 这一点特别令人困惑,因为它表明愤怒的字面不变具有长期价值。 该建议与DCL02-C. 使用直观识别符号相似。
同样,你在表示愤怒的字面不变是长期价值时,应当使用LL而不是低地壳。
MISRA C++ 2008, for the C++03 Language states in rule M2-13-3 (at particular, asquot by this :Autosar document
A “U” suffix shall be applied to all octal or hexadecimal integer literals of unsigned type.
链接文件还比较了2005年共同财产法和HIC++v4.0,所有这四项标准都要求组合为上层。
尽管如此,我还是找不到一条规则(但我没有手头上的MISRA C++的硬拷贝),即只要需要,就应当使用这些缺陷。 然而,国际排雷中心在MISRA C++中有一个。 (或可能只是我的前公司编码准则......)
I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...
I have been searching for sample code creating iterator for my own container, but I haven t really found a good example. I know this been asked before (Creating my own Iterators) but didn t see any ...
Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...
I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?
Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...
Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...
I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...
Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?