vectors help

well im trying to add onto the vector.. But i did get erase to work

1
2
3
4
5
typedef std::vector<unsigned char> ptr;

//now that theres data in ptr i want to increase it by 4 (front)

ptr.insert( prt.begin(),prt.begin()+4 );


gives me a error..



Also does _CRTDBG_LEAK_CHECK_DF; at the end of the main a good way of checking for leaking memory? Is it accurate?
¿what error?
you can't do a function on a class, but on an object of that class. this would work:
ptr a;
a.insert( a.begin(), a.begin()+4 );
EDIT:coder777: yea, it would!
Last edited on
Adding something to a vector is usually a push_back().

You can also resize() the vector.

Look at this: http://www.cplusplus.com/reference/stl/vector/

viliml wrote:
this would work
no it wouldn't ;)
EDIT:coder777: yea, it would!


There isn't a version of insert that matches those parameters.

Topic archived. No new replies allowed.