【发布时间】:2015-09-21 10:56:46
【问题描述】:
我正在编写此代码,但出现此错误:
[错误] 将 'const std::vector' 作为 'void std::vector<_tp _alloc>::push_back(const value_type&) 的 'this' 参数传递 [with _Tp = metastock7, _Alloc = std::allocator , std::vector<_tp _alloc>::value_type = metastock7]' 丢弃限定符 [-fpermissive]
struct A{
string name;
vector<B> rows;
};
set<A, classcomp> set;
vector<B> data; //I filled the vector in my code
std::set<A, classcomp>::iterator it;
std::pair<std::set<A, classcomp>::iterator,bool> ret;
for(int i = 0; i < data.size(); i++){
A a;
B b = data[i];
a.name= b.name;
ret = set.insert(a);
it = ret.first;
(*it).rows.push_back(b); //IT COMPILES WITHOUT
// it->rows.push_back(mstk7); //fails as well
}
我真的不明白这个错误。你能帮忙吗?
谢谢。
【问题讨论】:
标签: c++ pointers vector iterator set