Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
这可以出现在类声明中,还是我不使用#define常量会冒问题的风险sNumInts?
#define
sNumInts
static const int sNumInts = 15; std::array<int,sNumInts> myInts;
这是完全合法的。sNumInts是一个积分常数表达式 (ICE),可以在编译时使用机器(包括模板元编程)进行操作和创建。但是,一个的简单创建就像您定义的那样。