【发布时间】:2015-12-05 21:44:58
【问题描述】:
我收到错误:
expected primary-expression before '.' token
在以下程序中:
#include <iostream>
int main() {
struct a {
int y;
};
int n = 0;
n = a.y;
std::cout << "n: " << n << "\n";
return 0;
}
我在 vim 中使用 gcc g++ 编译器和 Syntastic。这不应该工作吗?
【问题讨论】:
-
你没有实例化 a.尝试结构 a b; n=b.y;