array within array

Hello all,
I have an array in C++. I want to change some of its elements to another array.In other words, I want to store some arrays inside another array.
How can I do this?
Thanks.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <iostream>
#include <vector>

int main()
{
    // https://cal-linux.com/tutorials/vectors.html
    std::vector< std::vector<int> > array_of_arrays ; // array of array of int ;

    array_of_arrays.push_back( { 10, 11, 12, 13 } ) ;

    array_of_arrays.resize(4) ;

    array_of_arrays[1] = { 14, 15, 16 } ;
    array_of_arrays[2] = { 17 } ;
    array_of_arrays[3] = { 18, 19, 20, 21, 22, 23 } ;

    array_of_arrays[0].push_back(99) ;

    for( const auto& array : array_of_arrays )
    {
        std::cout << "[ " ;
        for( int v : array ) std::cout << v << ' ' ;
        std::cout << "]\n" ;
    }
}

http://coliru.stacked-crooked.com/a/5c3449203c85e9fa
Hi,
while running, I encountered with the following error:
Error: Symbol {10,11,12,13} is not defined in current scope a.cxx:11:
Which compiler (and version) are you using?
my compiler is gcc 4:4.6.3-1ubuntu5.
IIRC, it should compile cleanly with these options: -std=c++0x -Wall -Wextra -pedantic-errors
Topic archived. No new replies allowed.