看板 EE_DSnP 關於我們 聯絡資訊
有幾個看不懂的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
jjjj222:(*its).getId() 12/21 21:14
jjjj222:or (*its)->getId()? since the data in vector is an ptr 12/21 21:15
jjjj222:switch can only accept "int", and x.c_str() is char* 12/21 21:17
jjjj222:I think you should use "ilo[0]" 12/21 21:18
meanid:got it!! thx!! 12/21 21:37