Sign in to follow this  
lonewolff

How to instantiate a 'new' STL vector?

Recommended Posts

Hi guys,
 
How do you instantiate a 'new' for STL vectors?
 
I have a vector of int's but if I try to exceed 1330 instances the application throws memory exceptions. So I want to pre-allocate the space with 'new'.
 
int frames = 1330; // 1330 max without 'new'
std::vector<int>* anim = new std::vector<int> anim(frames);
 
This doesn't compile, but hopefully gives an indication of what I want to do.
 
Any help would be greatly appreciated.
 
Thanks in advance :)

Share this post


Link to post
Share on other sites

You should never really need new/delete. As mentioned above, you can use a vector< vector<int> > if you want a 2D array. Any statement where new and vector are combined is an oxymoron.

Edited by sjhalayka

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this