컴파일되지 않습니다 :'std :: vector <T> :: iterator it;' 나는이 기능을 가지고
template<typename T>
void Inventory::insertItem(std::vector<T>& v, const T& x)
{
std::vector<T>::iterator it; // doesn't compile
for(it=v.begin(); it<v.end(); ++it)
{
if(x <= *it) // if the insertee is alphabetically less than this index
{
v.insert(it, x);
}
}
}
및 g 것은 ++ 이러한 오류 제공 :
src/Item.hpp: In member function ‘void
yarl::item::Inventory::insertItem(std::vector<T, std::allocator<_CharT> >&, const T&)’:
src/Item.hpp:186: error: expected ‘;’ before ‘it’
src/Item.hpp:187: error: ‘it’ was not declared in this scope
뭔가 간단합니다,하지만 내가 할 수있는 그것을 쳐다보고 십 분 ' 잘못된 것을 찾지 마라. 누구든지 그것을 볼 수 있습니까?
btw을 사용하면'it