| | |
vector array
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Feb 2008
Posts: 517
Reputation:
Solved Threads: 1
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.
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)
std::vector<std::vector<string> > Value(100, std::vector<string>(100));
Last edited by Jennifer84; Feb 13th, 2008 at 10:38 pm.
Remember, of course, that in C++ everything is zero-based. So
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.
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.
![]() |
Similar Threads
- get length of a dynamic array (C++)
- string array size (C++)
- String to array (C++)
- Declaring string array, initializing later... (C++)
- stl vector - can you delete by position? (C++)
- Made my own vector thingy (C)
- Help using an Array (C)
- can a vector take array of char(char *) (ASP.NET)
- Reversive Array/Integer (C)
Other Threads in the C++ Forum
- Previous Thread: Adding Multidemensional Arrays
- Next Thread: Can anyone help me with adding 2 polynomials together?
| Thread Tools | Search this Thread |
api array arrays beginner binary bitmap c++ c/c++ calculator char char* class classes coding compile compiler console conversion convert count data database delete desktop developer directshow dll dynamic dynamiccharacterarray email encryption error file forms fstream function functions game getline google graph homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference return rpg sorting string strings struct template templates test text tree unix url vector video visualstudio win32 windows winsock word wordfrequency wxwidgets






