1 c++ syntax macros function
我在C++编程,我将一个变量定义为宏,我想使用宏从函数返回一个值.
由于某种原因,编译器说我有语法错误.我正在使用Linux.
#include <iostream> #define FACTOR 10; int dosomthing(){ return (FACTOR/2); }
什么可能出错?
Red*_*edX 9
宏被替换.所以最终你会得到
return (10;/2);
只需;从你的宏中移除你就可以了.
;
Axe*_*ing 5
static const int FACTOR = 10; 是在C++中更好的方法.
static const int FACTOR = 10;
归档时间:
14 年,7 月 前
查看次数:
236 次
最近记录:
13 年,3 月 前