65,209
社区成员
发帖
与我相关
我的任务
分享
// a.hpp
extern int x; // 只有声明
struct C
{
static int y; // 只有声明
};
// a.cpp
#include "a.hpp"
int main()
{
::x = 1; // 报错:undefined reference to `x'
C::y = 2; // 报错:undefined reference to `C::y'
}
// 解决办法就是把缺少的定义加上
// int x;
// int C::y;