Array of pairs, gibberish output (unallocated memory?)
<p>Coming from Java I was trying to implement a simple Battleships game in C++ but already got stuck at this Array:</p>

<pre><code>#include &lt;iostream&gt;
#include &lt;utility&gt;

using namespace std;

class Ship{
    private:
        int length;
        bool direction; //false = left, true = down
        pair &lt;int,int&gt; coords[];
    public:
        Ship(int x, int y, bool, int);
        void printship();
};

Ship::Ship(int x, int y, bool dir, int l){ 
    pair &lt;int,int&gt; coords[l];
    length = l;
    if (dir){
        for (int i = 0; i &lt; l; i++){
            coords[i] = make_pair(x, y+i);
        }   
    }   
    else{
        for (int i = 0; i &lt; l; i++){
            coords[i] = make_pair(x+i, y); 
        }   
    }   
}
void Ship::printship(){
    for (int i = 0; i &lt; length; i++){
        cout &lt;&lt; "x: " &lt;&lt; coords[i].first &lt;&lt; ", y: " &lt;&lt; coords[i].second &lt;&lt; endl;
    }   
}

int main(){
    Ship tests(2,3,true,3);
    tests.printship();
    return 0;
}
</code></pre>

<p>What I get is:</p>

<pre><code>x: 134515168, y: 0
x: 0, y: 9938131
x: 1, y: -1080624940
</code></pre>

<p>I guess something is pointing to unallocated memory, but I can't figure out what, and why.</p>
