Why do I have to initialize pointers as variables?
<p>This piece of code below works fine.
// example on constructors and destructors</p>

<pre><code>#include &lt;iostream&gt;
using namespace std;

class CRectangle {
    int *width, *height;
  public:
    CRectangle (int,int);
    ~CRectangle ();
    int area () {return (*width * *height);}
};

CRectangle::CRectangle (int a, int b) {
  width = new int;
  height = new int;
  *width = a;
  *height = b;
}

CRectangle::~CRectangle () {
  delete width;
  delete height;
}

int main () {
  CRectangle rect (3,4), rectb (5,6);
  cout &lt;&lt; "rect area: " &lt;&lt; rect.area() &lt;&lt; endl;
  cout &lt;&lt; "rectb area: " &lt;&lt; rectb.area() &lt;&lt; endl;
  return 0;
}
</code></pre>

<p>But why couldn't I use another piece of code below instead? It didn't compile by using the code below but if I force to run it will still generate correct result.</p>

<pre><code>#include &lt;iostream&gt;
using namespace std;

class CRectangle {
  //here I didn't initialize these two variables' pointers.
  int width, height;
public:
  CRectangle (int a,int b);
  ~CRectangle ();
  int area () {
    return (width * height);
  }
};

CRectangle::CRectangle (int a, int b) {
  width = a;
  height = b;
}

CRectangle::~CRectangle () {

}

int main () {
  CRectangle rect (3,4), rectb (5,6);
  cout &lt;&lt; "rect area: " &lt;&lt; rect.area() &lt;&lt; endl;
  cout &lt;&lt; "rectb area: " &lt;&lt; rectb.area() &lt;&lt; endl;
  return 0;
}
</code></pre>
