C++, Why does my program hangs when I use this kind of array to store data?
<p>My program just simply hangs when I am trying to enter any coordinate for x pt.1.</p>

<p>Anyone can help me please??</p>

<pre><code>// shape.h
#include &lt;string&gt;
#ifndef SHAPE_H
#define SHAPE_H 1
using namespace std;

class Shape
{

protected:
    int x, y;
    string name;
public:
// a simple inline constructor
    Shape(int new_x, int new_y, string new_name): x(new_x), y(new_y), name(new_name)
    {
        return;
    };

    virtual ~Shape()
    {
        return;
    };
// inline getter/setter functions
    string getName() { return name; };
    void setName(string new_name)
    {
        name = new_name;
    }

    int getX() { return x; };
    void setX(int set_x)
    {
        x = set_x;
    }

    int getY() { return y; };
    void setY(int set_y)
    {
        y = set_y;
    }

    void toString();
};
#endif 
</code></pre>

<p>the shape header. this program is about inheritance too..</p>

<pre><code>// square.h
#ifndef SQUARE_H
#define SQUARE_H 1
#include &lt;string&gt;
#include "Shape.h"
using namespace std;

class Square : public Shape
{
protected:
int size;
public:
// a c'tor that calls the parent class's c'tor
Square(int new_x, int new_y, string new_name): Shape(new_x, new_y, new_name)
{
    return;
};

void setXY();
Square *arraySquare[1];
};

void Square::setXY()
{
int count = 0;
for(int i=0; i&lt;4; i++)
{
    cout&lt;&lt;"Please enter x-ordinate of pt. "&lt;&lt;i+1&lt;&lt;" : ";
    cin&gt;&gt;x;
    arraySquare[count]-&gt;setX(x);
    cout&lt;&lt;"Please enter y-ordinate of pt. "&lt;&lt;i+1&lt;&lt;" : ";
    cin&gt;&gt;y;
    arraySquare[count]-&gt;setY(y);
    count++;
}
}

#endif  
</code></pre>

<p>square header.. a subclass of shape..</p>

<pre><code>#include &lt;iostream&gt;
#include &lt;string&gt;
#include "Shape.h"
#include "Square.h"
using namespace std;

class Main
{
public:
    void mainMenu();
    char menuChoice;
    void stringToUpper(string &amp;s);
};

void stringToUpper(string &amp;s)
{
    for(unsigned int l = 0; l &lt; s.length(); l++)
    {
        s[l] = toupper(s[l]);
    }
}

void Main::mainMenu()
{
    cout&lt;&lt;"Welcome to Main program!"&lt;&lt;endl&lt;&lt;endl;
    cout&lt;&lt;"1)   Input data"&lt;&lt;endl;
    cout&lt;&lt;"2)   2"&lt;&lt;endl;
    cout&lt;&lt;"3)   3"&lt;&lt;endl;
    cout&lt;&lt;"4)   4"&lt;&lt;endl;
    cout&lt;&lt;"Q)   Enter 'Q' to quit"&lt;&lt;endl&lt;&lt;endl;
}

int main()
{
    char menuChoice;

    bool quit=false;
    Main main;
    Square *square;

    string shape, special;

    while ( !quit )
    {
        main.mainMenu();
        cout&lt;&lt;"Please enter your choice : ";
        cin&gt;&gt;menuChoice;
        menuChoice = toupper(menuChoice);

        switch(menuChoice)
        {
            case '1':
            cout&lt;&lt;endl&lt;&lt;"[ Input data ]"&lt;&lt;endl;
            cout&lt;&lt;"Please enter name of shape : "&lt;&lt;endl;
            cin&gt;&gt;shape;
            stringToUpper(shape);
            if(shape=="SQUARE")
            {
                square-&gt;setXY();
            }
            break;
            case '2':
            cout&lt;&lt;"Print"&lt;&lt;endl&lt;&lt;endl;
            break;           
            case '3':
            cout&lt;&lt;"You choosen 3"&lt;&lt;endl&lt;&lt;endl;
            break;                   
            case '4':
            cout&lt;&lt;"You choosen 4"&lt;&lt;endl&lt;&lt;endl;
            break;
            case 'Q':
            cout&lt;&lt;"You have chosen to quit!"&lt;&lt;endl&lt;&lt;endl;
            quit=true;
            exit(0);                 
            default:
            cout&lt;&lt;"Invalid entry!"&lt;&lt;endl&lt;&lt;endl;
            break;
        }
    }
}
</code></pre>

<p>this is the face of the program..</p>

<p>it just hangs whenever i run it and enter the first coordinate x. Anyone can help?</p>
