【发布时间】:2014-02-19 05:01:41
【问题描述】:
我仍然对 c++ 相当生疏,我无法理解我的问题。我收到的错误消息是“没有运算符 '
for(int i = 0; i < ruleList.size(); i++)
{
cout << ruleList[i].lhs << endl;
cout << ruleList[i].rhs << endl; // Problem printing this
}
struct Rules
{
string lhs;
vector<string> rhs;
}rule;
vector<Rules> ruleList;
这样做是否合适?我用同样的方法做了 lhs,效果很好。
rule.rhs.push_back(token);
ruleList.push_back(rule);
【问题讨论】:
-
无法直接使用
cout打印vector。循环遍历向量并逐个打印每个元素,