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<4; i++)
{
cout<<"Please enter x-ordinate of pt. "<<i+1<<" : ";
cin>>x;
arraySquare[count]->setX(x);
cout<<"Please enter y-ordinate of pt. "<<i+1<<" : ";
cin>>y;
arraySquare[count]->setY(y);
count++;
}
}
So a Square has an array of one pointer to Square? This pointer is never initialized so it's pointing to some random place in memory. You then try to write to the memory it's pointing to. You then try to access it as if it is an array larger than one element, interpreting more random memory as a pointer to.. random memory, which you then try to write to.
Well, the obvious thing would be to remove arraySquare from the Square class, since a square should not be a container of squares (or pointers to squares.)