[ns] Vectors in NS

Daniel Mahrenholz mahrenholz at rt-solutions.de
Thu Mar 6 04:02:26 PST 2008


Hi,

vector.erase(...) works only on iterators. Look here for more 
information: http://www.cplusplus.com/reference/stl/vector/erase.html

Daniel.


SS Mukaka schrieb:
> Dear All
>
> How do you define and manipulate vectors in C++ code.
> I have written my own protocol but I'm having problems with the vectors
>
> Here is how I defined my vector:
>
> vector <int> MyVector
>
> and this is how I manipulate it
>
> MyVector.erase(index)
> MyVector. push_back(DataItem)
>
> This is the error that I get when I try to compile my code (using make)
>  error: no matching function for call to 'std::vector<int,
> std::allocator<int> >::erase(int)'
> /usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../include/c++/4.1.2/bits/vector.tcc:110:
> note: candidates are: typename std::vector<_Tp, _Alloc>::iterator
> std::vector<_Tp, _Alloc>::erase(__gnu_cxx::__normal_iterator<typename
> std::_Vector_base<_Tp, _Alloc>::_Tp_alloc_type::pointer, std::vector<_Tp,
> _Alloc> >) [with _Tp = int, _Alloc = std::allocator<int>]
> /usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../include/c++/4.1.2/bits/vector.tcc:122:
> note:                 typename std::vector<_Tp, _Alloc>::iterator
> std::vector<_Tp, _Alloc>::erase(__gnu_cxx::__normal_iterator<typename
> std::_Vector_base<_Tp, _Alloc>::_Tp_alloc_type::pointer, std::vector<_Tp,
> _Alloc> >, __gnu_cxx::__normal_iterator<typename std::_Vector_base<_Tp,
> _Alloc>::_Tp_alloc_type::pointer, std::vector<_Tp, _Alloc> >) [with _Tp =
> int, _Alloc = std::allocator<int>]
>
> Regards
>
> SS Mukaka
>   



More information about the Ns-users mailing list