[英]C++ push_back compiler error "
I am trying to add a struct to a vector of structs. 我试图在结构的向量中添加一个结构。
vector<udtWChar2> n;
vector<udtTag>_tags;
for (unsigned t=0;t<_tags.size();t++)
{
udtTag &nt=_tags[t];
for (int i=nt.PosStartTag;i<nt.PosStartTag+nt.CoveredLen;i++)
{
n[i].Tags.push_back[nt];
}
}
The error I am getting is in the line 我得到的错误是在行
n[i].Tags.push_back[nt];
"A pointer to a bound function may only be called to invoke the function". “只能调用指向绑定函数的指针来调用函数”。
Here are my declarations: 这是我的声明:
struct udtTag
{
int PosStartTag;
int LenStartStart;
int PosEndTag;
int LenEndTag;
int CoveredLen;
eTagType Type;
wstring Value;
};
struct udtWChar2
{
wstring Text;
int OrigPos;
int AbsSpeed;
int Bookmark;
bool IsTag;
vector<udtTag>Tags;
};
I don't see what I did wrong. 我不明白我做错了什么。 Can somebody please help?
有人可以帮忙吗? Thank you.
谢谢。
The expression Tags.push_back[nt]
is not a call of method push_back
. 表达式
Tags.push_back[nt]
不是方法push_back
的调用。 The compiler thinks you want to call push_back.operator[]
. 编译器认为你想调用
push_back.operator[]
。 Replace the square brackets with parentheses: 用括号替换方括号:
... Tags.push_back(nt);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.