在下面的程序中我已经使用了静态const int init。但它是抛出错误 /tmp/ccEkWmkT.o(.text+0x15d):在函数check::operation()': : undefined reference to
检查::初始化'使用编译时常量抛出错误
此错误是只有当使用矢量。有人可以帮忙吗?什么是确切的行为?
#include<vector>
#include<iostream>
using namespace std;
class check{
static const int init=1;
public:
check(){}
void operation();
};
void check::operation(){
vector<int> dummy;
dummy.push_back(init);
}
int main(){
check ck;
ck.operation();
}
+1,不错的角落案例。 – iammilind