作者meanid (meanid)
看板EE_DSnP
标题[问题] compile error
时间Wed Dec 21 21:03:37 2011
有几个看不懂的error麻烦强者帮我解答一下...
第一个:
cirMgr.cpp:234: error: ‘class __gnu_cxx::__normal_iterator<CirPiGate**,
std::vector<CirPiGate*, std::allocator<CirPiGate*> > >’ has no member named ‘
getId’
code:
vector<CirPiGate*>::iterator its;
its = _pi.begin();
for(; its< _pi.end(); its++)
if(its.getId() == id)
.
.
.
_pi是一个我用来存CirPiGate*的vector
CirPiGate 是一个计承 CirGate 的 class
以上四行code是在一个switch case里面的
我检查过了里面有getId 这个 member function(在CirGate里面,非virtual)
第二个:
cirMgr.cpp:303: error: switch quantity not an integer
code:
switch(ilo.c_str()){
.
.
.
ilo是一个只有一个字的string
想把它转成char来判断
不知道这样转可不可以??
麻烦各位了QQ
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.112.25.108
1F:推 jjjj222:(*its).getId() 12/21 21:14
2F:推 jjjj222:or (*its)->getId()? since the data in vector is an ptr 12/21 21:15
3F:推 jjjj222:switch can only accept "int", and x.c_str() is char* 12/21 21:17
4F:推 jjjj222:I think you should use "ilo[0]" 12/21 21:18
5F:→ meanid:got it!! thx!! 12/21 21:37