943,691 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 2506
  • C++ RSS
Feb 13th, 2008
0

vector array

Expand Post »
whats the different between two multidimensional vector and array?
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
aircraft is offline Offline
11 posts
since Feb 2008
Feb 13th, 2008
0

Re: vector array

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.

C++ Syntax (Toggle Plain Text)
  1. std::vector<std::vector<string> > Value(100, std::vector<string>(100));

Click to Expand / Collapse  Quote originally posted by aircraft ...
whats the different between two multidimensional vector and array?
Last edited by Jennifer84; Feb 13th, 2008 at 10:38 pm.
Reputation Points: 10
Solved Threads: 1
Posting Pro
Jennifer84 is offline Offline
563 posts
since Feb 2008
Feb 13th, 2008
0

Re: vector array

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.
Featured Poster
Reputation Points: 1140
Solved Threads: 229
Postaholic
Duoas is offline Offline
2,039 posts
since Oct 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Adding Multidemensional Arrays
Next Thread in C++ Forum Timeline: Can anyone help me with adding 2 polynomials together?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC