对于c ++,jour首选的命名约定是什么? [英] What is the preferred naming conventions du jour for c++?

查看:85
本文介绍了对于c ++,jour首选的命名约定是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对boost库和stl,然后再看人们的示例感到很困惑.似乎大写的类型名散布在所有小写字母之间,并用下划线分隔.

I am quite confused by looking at the boost library, and stl, and then looking at people's examples. It seems that capitalized type names are interspersed with all lowercase, separated by underscores.

这几天应该怎么做?我知道.NET世界有自己的一套约定,但它似乎与C ++领域完全不同.

What exactly is the way things should be done these days? I know the .NET world has their own set of conventions, but it appears to be completely different than the C++ sphere.

推荐答案

您打开过的蠕虫病毒罐有多大.

What a can of worms you've opened.

C ++标准库对所有内容都使用 underscore_notation ,因为这就是C标准库所使用的.

The C++ standard library uses underscore_notation for everything, because that's what the C standard library uses.

因此,如果您希望代码在各个方面看起来都是一致的(实际上并没有使用外部库),那是唯一的方法.

So if you want your code to look consistent across the board (and actually aren't using external libraries), that is the only way to go.

您会看到boost使用相同的表示法,因为通常会考虑将其库用作将来的标准.

You'll see boost use the same notation because often their libraries get considered for future standards.

除此之外,还有许多约定,通常使用不同的符号来指定不同类型的符号.通常将 CamelCase 用于自定义类型,例如类和typedefs和 mixedCase 用于变量,专门用于区分这两个变量,但这当然不是通用标准.

Beyond that, there are many conventions, usually using different notations to designate different types of symbols. It is common to use CamelCase for custom types, such as classes and typedefs and mixedCase for variables, specifically to differentiate those two, but that is certainly not a universal standard.

还有 匈牙利表示法 ,它进一步区分了特定的变量类型,尽管仅提及该短语会激起一些编码人员的敌意.

There's also Hungarian Notation, which further differentiates specific variable types, although just mentioning that phrase can incite hostility from some coders.

作为一名优秀的C ++程序员,最佳答案是采用您所浸入的代码中使用的任何约定.

The best answer, as a good C++ programmer, is to adopt whatever convention is being used in the code you're immersed in.

这篇关于对于c ++,jour首选的命名约定是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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