vector array

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Feb 2008
Posts: 11
Reputation: aircraft is an unknown quantity at this point 
Solved Threads: 0
aircraft aircraft is offline Offline
Newbie Poster

vector array

 
0
  #1
Feb 13th, 2008
whats the different between two multidimensional vector and array?
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 517
Reputation: Jennifer84 is an unknown quantity at this point 
Solved Threads: 1
Jennifer84 Jennifer84 is offline Offline
Posting Pro

Re: vector array

 
0
  #2
Feb 13th, 2008
You could see it as rows and columns, as Excel is built.
It is a useful when you want to structure things for easy access.
So for the 2D vector in the code below you have 100 rows and 100 columns.

So if you write: Value[1][10]
You are accessing the first row in the 10:th column.

Hope this helps to understand.

  1. std::vector<std::vector<string> > Value(100, std::vector<string>(100));

Originally Posted by aircraft View Post
whats the different between two multidimensional vector and array?
Last edited by Jennifer84; Feb 13th, 2008 at 10:38 pm.
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 1,951
Reputation: Duoas has much to be proud of Duoas has much to be proud of Duoas has much to be proud of Duoas has much to be proud of Duoas has much to be proud of Duoas has much to be proud of Duoas has much to be proud of Duoas has much to be proud of 
Solved Threads: 214
Featured Poster
Duoas's Avatar
Duoas Duoas is offline Offline
Posting Virtuoso

Re: vector array

 
0
  #3
Feb 13th, 2008
Remember, of course, that in C++ everything is zero-based. So Value[1][10] is the second row and the eleventh column.

A vector, as Jennifer84 demonstrates, is a superior construct, since you get all the benefits of an array without any of the drawbacks.

[EDIT] Oh yeah, almost forgot to answer your Q. A vector is a "container class" in the STL. Read what the C++ FAQ has to say about it here.
Last edited by Duoas; Feb 13th, 2008 at 11:38 pm.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC