如下代码产生如下错误:
test.cpp: In function `int main()':
test.cpp:15: error: cannot convert `__gnu_cxx::__normal_iterator<label**, std::vector<label*, std::allocator<label*> > >' to `label**' in initialization
#include
<
iostream
>
#include
<
vector
>
using
namespace
std;

struct
label
{
int x;
int y;
}
;

int
main()
{
vector<label*> plabel;
label ** pCurrlabel = plabel.begin();
return 0;
}
改为
label
*
pCurrlabel
= *
(plabel.begin());
就好了。
因为 plabel.begin()返回的是一个迭代器,并不能自然地转化为指针。
(摘自:www.linuxquestions.org)
test.cpp: In function `int main()':
test.cpp:15: error: cannot convert `__gnu_cxx::__normal_iterator<label**, std::vector<label*, std::allocator<label*> > >' to `label**' in initialization

















改为

因为 plabel.begin()返回的是一个迭代器,并不能自然地转化为指针。
(摘自:www.linuxquestions.org)