在c++,c中宏的使用和全局静态变量的使用

来源:互联网 发布:linux svn 分支 编辑:程序博客网 时间:2024/06/07 04:25
C,C++通用代码,用C的习惯用法
纯粹C++用C++的习惯用法

C:(C,C++ 通用)
C/C++ code
?
1
2
3
4
1)
#define      PI        3.14
2)
enum{     red,green,blue  };



C++:

C/C++ code
?
1
2
3
4
5
6
7
8
9
10
11
12
13
const double pi =3.14;
const int black =0;
 
class Color{
union{
unsigned int color;
struct{
unsigned char r,g,b,a;
}
unsigned carr[4];
};
static const int black = 0;  
};
0 0
原创粉丝点击