ただいま継承作業中です。Shape と呼ばれる基本クラスと、サブクラスとして他にいくつかあります。コンパイルエラーはありません。しかし、すべての座標を入力すると、セグメンテーション エラーが発生します。ドライバー クラス内で、この d[count].toString(); を使用しようとしたときのオプション。
シェイプ.h
class Shape
{
  protected:
     string name;
     bool containsWarpSpace;
  public:
    Shape();
    Shape(string, bool);
    string toString();
    virtual double computeArea();
    void setName (string);
    // some other codes here
 };
Square.h
class Square : public Shape
{
protected:
    int *x;
    int *y;
    int area;
    int vertices;
public:
    double computeArea();
    void setSquare(string, string, int*, int*);
    string toString();
};
Square.cpp
void Square::setSquare(string name, string type, int* a, int* b)
{
setName(name);
setContainsWarpSpace (type);
vertices = 4;
x = new int[vertices];
y = new int[vertices];
for (int i = 0; i < vertices; i++)
{
    x[i] = a[i];
    y[i] = b[i];
}
}
string Square::toString()
{
    ostringstream convert;
    string s;
string type;
for (int i = 0; i < vertices; i++)
{
    convert << "point " << i + 1 
        << " ( "            
        << x[i] << " , " << y[i] 
        << " ) "<< endl;
}
 s = convert.str();
return s;
}
int main() を使用したドライバー クラス
class Driver
 {
public:
    Driver();
    Shape *d[];
    Square *s;      
    int count;
    int noSquare;
    int noRectangle;
    int noCross;
    void printDetails();
    void printPlan();
    void option1();
    void option2();
    void option3();
    void option4();
    string convertString(string);
 };
Driver.cpp. これはデフォルトのコンストラクターです。
Driver :: Driver()
{
Shape d [MAX];
s = new Square [MAX];
count = 0;
int noSquare = 0;
int noRectangle = 0;
int noCross = 0;
  }
  Driver::option1()
   {
if (shape.compare("square") == 0)
{
    tempx = new int[4];
    tempy = new int[4];
    for (int i = 0; i < 4; i++)
    {
        int j = i + 1;
        cout << "Please enter x-ordinate of pt " << j << ": ";
        cin >>tempx[i];        
        cout << "Please enter y-ordinate of pt " << j << ": ";
        cin >>tempy[i];      
    }
    s[noSquare].setSquare(shape,type, tempx,tempy);
    d[count] = &s[noSquare];
            d[count].toString();    
}
}
int main ()
{
    option1();
}