user6549: I have included the STL library in Arduino and i can run a program with 1D vector.
But i am getting error while declaring a 2D vector.  
#include <StandardCplusplus.h>
#include <serstream>
#include<vector>
#include<iterator>

using namespace std;

vector <vector<int> > grid;
vector<int> col(5,3);
grid.push_back(col);

void setup()
{
    Serial.begin(9600);
}

void loop()
{
  for(int i = 0; i < 5; i++)
  {
    Serial.println(grid[[0][i]);
  }
}

And the error is 
'grid' does not name a type.   

Do i need to add another header file?

user1677: The error is coming from 
 grid.push_back(col);

You cannot have this line at the top-most level outside a function / main. Move it inside setup or loop.

6549: <p>I have included the STL library in Arduino and i can run a program with 1D vector.
But i am getting error while declaring a 2D vector.  </p>

<pre><code>#include &lt;StandardCplusplus.h&gt;
#include &lt;serstream&gt;
#include&lt;vector&gt;
#include&lt;iterator&gt;

using namespace std;

vector &lt;vector&lt;int&gt; &gt; grid;
vector&lt;int&gt; col(5,3);
grid.push_back(col);

void setup()
{
    Serial.begin(9600);
}

void loop()
{
  for(int i = 0; i &lt; 5; i++)
  {
    Serial.println(grid[[0][i]);
  }
}
</code></pre>

<p>And the error is </p>

<pre><code>'grid' does not name a type.   
</code></pre>

<p>Do i need to add another header file?</p>
 1677: <p>The error is coming from </p>

<pre><code> grid.push_back(col);
</code></pre>

<p>You cannot have this line at the top-most level outside a function / main. Move it inside <code>setup</code> or <code>loop</code>.</p>
