预处理命令中的#和##
来源:互联网 发布:java多线程异步调用 编辑:程序博客网 时间:2024/04/28 01:10
在c/c++的程序设计中,有的时候不免要实现某些对象转换出相应名字字符串或两对象名直接相连的情况,这时候可采用宏定义中加入#和##分别实现相应功能。下面是摘抄的一段解释。
The # and ## preprocessor operators are used with the #define preprocessor directive.
- Using # causes the first argument after the # to be returned as a string in quotes.
- Using ## concatenates what's before the ## with what's after it.
For example, the command
#define to_string( s ) # s
will make the compiler turn this command
cout << to_string( Hello World! ) << endl;
into
cout << "Hello World!" << endl;
Here is an example of the ## command:
#define concatenate( a, b ) a ## b ... int xy = 10; ...
This code will make the compiler turn
cout << concatenate( x, y ) << endl;
into
cout << xy << endl;
which will, of course, display '10' to standard output.
- 预处理命令中的#和##
- c++ 预处理和预处理命令
- C中的预处理命令
- C++中的预处理命令
- C中的预处理命令
- C++ 中的预处理命令
- C++中的预处理命令
- 预处理命令 # 和 ##
- Keil 中的预处理命令const
- C语言中的预处理命令
- C++/C中的预处理命令;
- C++中的编译预处理命令
- C 语言中的预处理命令
- LINUX 基础命令和预处理
- 预处理命令基础和常用预处理命令实例
- Keil C 中的预处理命令const
- Primer Plus C++中的预处理命令
- 预处理命令“ # 运算符”和“ ## 运算符”
- 手机耳机孔通信研究
- 我的微博
- tnsnames.ora配置小结
- winCE改变字库方法
- mldonkey 安装详细过程
- 预处理命令中的#和##
- volatile的作用
- C++中的强制转换
- 4字节单精度二进制浮点数的解码
- 一面微创题--字符串逆序输出
- Linux内存点滴 用户进程内存空间
- HTML简介:标记型解释型的语言
- Android动态添加SlidingDrawer抽屉控件 by 柱子ZHU-ZI
- linux SPI 设备驱动