C++ 命名规范小结
2015-10-07 22:18
387 查看
1. #defines and const
test.h#ifndef TEST_H #define TEST_H #endif
#define FALSE 0 #define TRUE (!FALSE)
#define MAX_NO_OF_STUDENT 100 const int MAX_NO_OF_STUDENT = 100;
2.Function(函数)
int m_iGetValues(); m_ : a member of a class i : returns a int
long m_lGetValues(); m_ : a member of a class l : returns a long
int * m_piGetValus(); m_ : a member of a class p : returns pointer i : a int pointer
void * m_pvDoSomething(); m_ : a member of a class p : returns pointer v : a void pointer
unsigned char ucGetValues(); uc : This returns unsigned char
bool bIsRunning(); b : returns a bool
void m_vSetValues(int iNum); m_ : a member of a class v : there is no return value
If the function is not a member of a class, then ‘m_’ prefix is not used.Example:
//global function int g_iGetValues(); g_ : a global functions i : returns a int
3.Variables(变量)
//在 int变量 的最前面加上一个小写的i,之后每个单词的第一个字母大写 int iNum; int iNoOfVariables;
//在数组的最前面加上a(array),然后紧接着一个数组类型的字母。 char acFileName[128]; ac代表一个字符类型的数组 int aiNum[128]; ai代表这是一个int类型的数组 char *apcFileName[128]; 这是一个数组,数组中保存着128个char类型的指针 char (*pacFileName)[128]; 这是一个指针,
//在变量的最前面加上 m_, 代表这是一个类或者是一个结构体中的成员变量。 typedef struct _SNode { char * m_pcName; //m_:结构体成员; pc:指向char类型的指针 struct _SNode * m_pstNext; //m_结构体成员; pst:指向struct类型的指针 }SNode;
相关文章推荐
- C++ 命名规范小结
- 【C语言】输出一个整数的每一位
- 一道腾讯笔试题【深、浅拷贝】
- 浅析C++中的is-a和has-a关系(公有继承、包含、私有继承)
- C语言基础-几个简单图形的打印
- 浅析C++中的is-a和has-a关系(公有继承、包含、私有继承)
- C语言合法标识符
- C/C++中字符的基本操作
- 【C语言】输出菱形星号图案
- vector data() [c++11]
- C++中的const关键字详解
- 数组中的逆序对数(C++版)
- C语言字符串那些事
- C语言字符串那些事
- c++中加载文件的路径,“\\”和“/”
- C++学习笔记之指针
- C++ 设计模式学习-网站
- C++输入输出
- c语言里‘...’意思是一个参数或者多个参数的意思
- C/C++ INI文件操作