vector of vectors

This is a discussion on vector of vectors within the C++ Programming forums, part of the General Programming Boards category; It tried using a vector of vectors, but for some reason it woouldn't compile. Can't remember the error, something about ...

  1. #1
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145

    vector of vectors

    It tried using a vector of vectors, but for some reason it woouldn't compile. Can't remember the error, something about a missing comma I think.
    Code:
    std::vector<std::vector<int>> MyVec;
    Either I'm making some stupid obvious mistake, or it's not possible this way.

    On a side-related note, I used a typedef and it compiled fine:
    Code:
    typedef std::vector<int> vec_int;
    std::vector<vec_int> MyVec;
    Why is the first not valid?
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  2. #2
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    You need to put a space between those last '>' otherwise it's seen as the '>>' operator, ie:
    Code:
    std::vector<std::vector<int> > MyVec;
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  3. #3
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    *Ouch*
    Yeah, that makes sense.
    Thanks!
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Vectors
    By naseerhaider in forum C++ Programming
    Replies: 11
    Last Post: 05-09-2008, 08:21 AM
  2. How can i made vectors measuring program in DevC++
    By flame82 in forum C Programming
    Replies: 1
    Last Post: 05-07-2008, 02:05 PM
  3. How properly get data out of vectors of templates?
    By 6tr6tr in forum C++ Programming
    Replies: 4
    Last Post: 04-15-2008, 10:35 AM
  4. How to use Vector's in C++ !?!
    By IndioDoido in forum C++ Programming
    Replies: 3
    Last Post: 10-14-2007, 11:13 AM
  5. Points, vectors, matrices
    By subnet_rx in forum Game Programming
    Replies: 17
    Last Post: 01-11-2002, 01:29 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21