I have seen stuff like this:
vector<int>
and stuff like that. What is it and what does it do. I know a lot of C++ and I have some experience w/ OpenGL and SDL, but I never used this stuff before. Any answers?
I have seen stuff like this:
vector<int>
and stuff like that. What is it and what does it do. I know a lot of C++ and I have some experience w/ OpenGL and SDL, but I never used this stuff before. Any answers?
Website(s): http://www16.brinkster.com/trifaze/
E-mail: [email protected]
---------------------------------
C++ Environment: MSVC++ 6.0; Dev-C++ 4.0/4.1
DirectX Version: 9.0b
DX SDK: DirectX 8.1 SDK
>I know a lot of C++
No you don't, try a decent C++ book. std::vector is part of the C++ standard template library, and is intended to replace the need to hand code an efficient generic dynamic array.
That is a vector class that uses templates. The templates allow the vector to be of any data type. You can look up info about the STL on google.com. As well you can d/l the current version of the STL from that site.
the stl is newer (i think) than a lot of c++
anyway... here's an example:
that's a small segment. the stl can sort it, swap two values, reverse (i think), and may other things. all of the above can be done on the whole list or just a small sectionPHP Code:
vector<vector <int> > array; // array of array of ints
vector <int> x;
x.push_back(3);
x.push_back(5); //x[0]=3, x[1]=5
x.push_back(7);
array.push_back(x); //neat, huh?
As with what ygf showed, a vector < vector <int> > can be made into a non-square matrix.