Storing a vector inside a vector

This is a discussion on Storing a vector inside a vector within the C++ Programming forums, part of the General Programming Boards category; Is this possible? Code: typedef std::vector<vector<Car>> Category; Category groupList; vector<Car> cars; groupList.push_back(cars);...

  1. #1
    Registered User
    Join Date
    Apr 2008
    Posts
    610

    Storing a vector inside a vector

    Is this possible?

    Code:
    typedef std::vector<vector<Car>> Category;
    
    Category groupList;
    
    vector<Car> cars;
    
    groupList.push_back(cars);

  2. #2
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,892
    Yes, but you need to separate the >> by a space so that it is parsed correctly.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. can some one please tell me the cause of the error ?
    By broli86 in forum C Programming
    Replies: 8
    Last Post: 06-26-2008, 08:36 PM
  2. syntax help?
    By scoobygoo in forum C++ Programming
    Replies: 1
    Last Post: 08-07-2007, 10:38 AM
  3. Vector class
    By Desolation in forum C++ Programming
    Replies: 2
    Last Post: 05-12-2007, 05:44 PM
  4. Need some help/advise for Public/Private classes
    By nirali35 in forum C++ Programming
    Replies: 8
    Last Post: 09-23-2006, 12:34 PM
  5. Certain functions
    By Lurker in forum C++ Programming
    Replies: 3
    Last Post: 12-26-2003, 12:26 AM

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