title: calling functions using "->"
body: <p>I'm currently learning about virtual functions, and in this particular lesson it creates an array of object pointers <code>firstArray[5]</code>, and calls functions from these objects. Until now, whenever I wanted to call a function <code>func()</code> from an object <code>foo</code>, I would write <code>foo.func()</code>. Now that I'm using virtual functions and this array, the book has switched to this method: <code>firstArray[0]-&gt;func()</code>. The book doesn't do a great job at justifying this switch, could someone please explain? I see that when I try to use <code>firstArray[0].func()</code>, I get this.... </p>
  
  <p><code>error: request for member 'func' in 'firstArray[0]', which is of non-class type 'sampleClass*'</code>.</p>
  
  <p>Is it simply because I'm trying to call a function from a pointer, not an actual object? I've been learning C++ for several months now, and for whatever reason pointers still trip me up sometimes. Any clarification would help.</p>
  
  <p>EDIT:</p>
  
  <p>I think the part that got me mixed up is this: I can create a pointer to a base object class with <code>base *ptr;</code>. Then, I can set that pointer by creating a new object from a derived class by saying <code>ptr = new derived;</code>. This is where I get confused. If I were to create an <code>int* ptr;</code>, and I wanted it to point to a integer I create, I couldn't say <code>ptr = int j</code>. If <code>ptr</code> is really just an address, why do these two examples work differently? I guess I don't understand the "new" mechanic very well either.</p>