在C ++中命名函数,方法,指针,变量,数组等 [英] Naming functions, methods, pointers, variables, arrays etc in C++

查看:180
本文介绍了在C ++中命名函数,方法,指针,变量,数组等的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,与几个朋友做一些项目,我需要一些标准在c ++中命名的东西。有没有人有任何好的命名方案的c ++是经过深思熟虑,而不是像10分钟。

Allright, doing some project with few friends, and I need some standard for naming things in c++. Does anyone have any good naming scheme for c++ that is well thought-out and not made in like 10min.

示例,int * house应该命名为int * house_p,当有人读取代码时,他不需要一直滚动来想知道一个东西是一个指针,数组,矩阵,还是其他...

Example, int* house should be named int* house_p, so that when someone reads the code, he doesn't need to scroll all the time wondering if a thing is a pointer, array, matrix, or whatever...

Post

推荐答案


示例,int * house应该被命名为
int * house_p,所以当有人
读取代码时,他不需要
滚动所有的时间想知道如果一个
事情是一个指针,数组,矩阵或
不管... ...

Example, int* house should be named int* house_p, so that when someone reads the code, he doesn't need to scroll all the time wondering if a thing is a pointer, array, matrix, or whatever...

但是如果它的类型改变了 - 并更改所有变量的名称。如果变量是复杂类型的实例,该怎么办:

But what if its type changes - are you going to go through all your code and change the names of all the variables. And what if the variable is an instance of a complex type:

ComplicatedDerivativeFinancialInstrument x;

您会使用什么后缀?

您问的是什么叫做匈牙利记法 - 它在C ++中的使用几乎被普遍认为是一个坏主意。

What you are asking about is known as Hungarian notation - its use in C++ is almost universally considered to be A Bad Idea.

这篇关于在C ++中命名函数,方法,指针,变量,数组等的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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