title: When to use pointer to a class and when to just instantiate it as a variable
body: <p>Im sort of confused by it. The best I could find was reading through the cplusplus.com tutorial and all they have to say about pointers to classes.</p>
  
  <p>"It is perfectly valid to create pointers that point to classes. We simply have to consider that once declared, a class becomes a valid type, so we can use the class name as the type for the pointer"</p>
  
  <p>Which tells me nothing about when to use them over the normal instantiation.
  I've seen the -> operator many times, and looked at some codes but cant really decipher why they did it.</p>
  
  <p>Generic examples will be appreciated; but more specifically related to gui programming. Its where I encountered it first.</p>
  
  <pre><code>QGridLayout *mainLayout = new QGridLayout;
  mainLayout-&gt;addWidget(nameLabel, 0, 0);
  mainLayout-&gt;addWidget(nameLine, 0, 1);
  mainLayout-&gt;addWidget(addressLabel, 1, 0, Qt::AlignTop);
  mainLayout-&gt;addWidget(addressText, 1, 1);
  </code></pre>
  
  <p>Why not </p>
  
  <pre><code>QGridLayout mainLayout
  mainLayout.addWidget
  ...
  </code></pre>
  
  <p>(It doesnt compile if I change the sample code to that and try it but you get the point)</p>
  
  <p>Thanks in advance</p>