Thread: vector<...>.....What is it?

  1. #1
    Programming is fun, mkay?
    Join Date
    Oct 2001
    Posts
    490

    Question vector<...>.....What is it?

    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

  2. #2
    S­énior Member
    Join Date
    Jan 2002
    Posts
    982
    >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.

  3. #3
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    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.

  4. #4
    Just because ygfperson's Avatar
    Join Date
    Jan 2002
    Posts
    2,490
    the stl is newer (i think) than a lot of c++

    anyway... here's an example:
    PHP Code:
    vector<vector <int> > array; // array of array of ints
    vector <intx;
    x.push_back(3);
    x.push_back(5); //x[0]=3, x[1]=5
    x.push_back(7);
    array.
    push_back(x); //neat, huh? 
    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 section

  5. #5
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,138
    As with what ygf showed, a vector < vector <int> > can be made into a non-square matrix.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. small -> big -> bigger -> bigger than bigger -> ?
    By happyclown in forum A Brief History of Cprogramming.com
    Replies: 9
    Last Post: 03-11-2009, 12:12 PM
  2. Dev-C++ -> Tools - > Editor -> Syntax
    By Yuri2 in forum C++ Programming
    Replies: 19
    Last Post: 07-03-2006, 07:48 AM
  3. > > > Urgent Help < < <
    By CodeCypher in forum C Programming
    Replies: 2
    Last Post: 01-31-2006, 02:06 PM
  4. static vector<...> in class problem.
    By alkis_y3k in forum C++ Programming
    Replies: 5
    Last Post: 01-29-2003, 04:13 PM