0
我正在嘗試這段代碼。我所試圖做的是在編譯時我收到以下錯誤,從類型結構從類型結構的向量中刪除元素
#include <iostream>
#include <vector>
#include <algorithm>
#include <boost/bind.hpp>
using namespace std;
typedef struct _detail
{
int y;
}detail;
typedef struct _list
{
int x;
detail det;
}list;
std::vector<list> v;
list li[5];
void PushElements()
{
for(int i = 0; i < 5; i++)
{
li[i].x = i+2;
li[i].det.y = i+3;
v.push_back(li[i]);
}
}
void display()
{
for(int i = 0; i < v.size(); i++)
{
cout << v[i].x << " ";
cout << v[i].det.y << " ";
}
cout << endl;
}
void DeleteElement()
{
std::vector<list>::iterator it = std::find_if(v.begin(), v.end(), boost::bind(&list::detail::y, _1) == 3);
v.erase(it);
}
int main()
{
PushElements();
display();
DeleteElement();
cout << "After Deleting...................." << endl;
display();
return 0;
}
的矢量刪除元素:
error C3083: 'detail': the symbol to the left of a '::' must be a type
error C2039: 'y' : is not a member of '_list'
error C2065: 'y' : undeclared identifier
我不明白這是什麼錯誤,以及如何解決它。有人可以幫我解決這個錯誤嗎?