#与##的用法
摘要:这两个符号很少被用到,不过很有意思。#:转换成字符串定义一个宏:#define to_string( s ) # s使用cout << to_string(Hello World!) << endl;相当于 cout<<"hello world"<<endl;##:连接你想连接的定义宏:#define concatenate( x, y ) x ## y使用int xy = 10;cout<<concatenate(x,y)<<endl;即使未知的东西, ##也能给连接起来了,可见其变态之处。
阅读全文
posted @ 2012-02-22 14:47

浙公网安备 33010602011771号