title: declaring an array using new in a class c++
body: <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  class Point {
      int x, y;
  public:
      Point ():x(0),y(0){};
      void setX (int xx){x = xx;};
      void setY (int yy){y = yy;};
      int getX (){return x;};
      int getY (){return y;};
  };
  
  class Polygon {
      int n;
      double degree;
      Point* vertex;
  public:
      Polygon (int nn):n(nn){
          degree = 360.0 / n;
          //vertex = new Point [n];
      };
  private:
      vertex = new Point [n];
  };
  </code></pre>
  <p>so I'm trying to declare vertex array using new, but I keep getting this error: data member initializer is not allowed</p>
  <p>is 'new' considered initializing?! and I tried doing it in constructor but I think it'll only work in constructor's scope.</p>
  <p>I'm also confused about this: n should be initialized before using new, so will this be solved if I just write the declaration after constructor?</p>