| | |
vector question
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Jun 2008
Posts: 158
Reputation:
Solved Threads: 3
Ok, I was wondering if somebody could give me some clarification on a topic that just doesn't seem to make sense to me. I have a class that tells my program all the attributes needed to build another player in my game but there could be 3 players logged in sometimes or 20 players logged in so it needs to be able to dynamically change all the time. I was told that using a vector could solve this problem because you can constantly change its value. But I am having problems understanding it. Would it be like for every player in the game there is another element added to the vector and it uses the sizeof function thing and thats how many objects it needs to instantiate from my class. I just need some further clarification on it. Any help is appreciated. Thanks.
•
•
Join Date: Oct 2007
Posts: 58
Reputation:
Solved Threads: 2
You can easily google STL vector information/documentation/library and learn from there.
Here are some basic features.
Vectors are similar to arrays but they are not fixed sizes, they can grow.
When the vector is close to its capacity it will allocate more space automatically.
There are functions to get element by index, get current amount of items in vector and more.
Vectors are templatized meaning it can only store 1 type of objects you can have vectors of ints, or chars, or in your case players but cant be ints and chars.
Here are some basic features.
Vectors are similar to arrays but they are not fixed sizes, they can grow.
When the vector is close to its capacity it will allocate more space automatically.
There are functions to get element by index, get current amount of items in vector and more.
Vectors are templatized meaning it can only store 1 type of objects you can have vectors of ints, or chars, or in your case players but cant be ints and chars.
![]() |
Similar Threads
- Vector Question (C++)
- DirectX and C++ DrawIndexedPrimitive question (C++)
- C++ vector question? (C++)
- Vector question (C)
Other Threads in the C++ Forum
- Previous Thread: i need help to prepare my program plz?
- Next Thread: Pls help me... in array problem..
| Thread Tools | Search this Thread |
api array based beginner binary bitmap c++ c/c++ calculator char class classes code compile compiler console conversion count delete deploy desktop developer directshow dll download dynamic dynamiccharacterarray encryption error file forms fstream function functions game getline givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory news node output parameter pointer problem program programming project proxy python read recursion recursive reference return rpg string strings struct temperature template templates test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets





