#### Archived

This topic is now archived and is closed to further replies.

# Is there a 2D version of the STL vector?

This topic is 6154 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I''m a newbie to the STL, and I was wondering, is there anything like a 2D array in it? My first thought was something like
  vector someArray; 
But that wouldn''t compile (I''m using Visual C++ 6). I also tried
  vector> someArray; 
But that wouldn''t compile either. Am I trying to do the impossible? Thanks, Anthracks

##### Share on other sites
As with arrays you would have an array of array''s - you can have a vector of vectors, declared thus:

  std::vector< std::vector > vec2d;

this compiles at least, I haven''t tried populating it but I can''t see why it wouldn''t work?

##### Share on other sites
you have to do

vector intvector;

##### Share on other sites
  vector> someArray;

That would work, but you have to be careful how you type it. In the line above, you have the >> operator (just after the int). You need a space between the two angle brackets for the line to parse correctly.

Aren`t templates fun

EDIT: Quote and source tags got mangled

Edited by - Krunk on November 15, 2001 5:19:57 PM

##### Share on other sites
Ah, thanks Krunk, you got it . I thought doing that made sense, I just didn't think of the lousy >> operator mixing things up.

Thanks all!

Anthracks

Edited by - Anthracks on November 15, 2001 5:54:01 PM

1. 1
2. 2
Rutin
19
3. 3
4. 4
5. 5
frob
13

• 9
• 15
• 10
• 9
• 17
• ### Forum Statistics

• Total Topics
632602
• Total Posts
3007363

×