title: accessing the member of a class of pointer array of another class
body: <p>I'm trying to figure out how I can or why I can't access the member of this class. First I'll show you what works so you know what I'm thinking, then I'll show you what I can't seem to do. </p>
  
  <p>What I can do is this: I have a class with a member. I make an pointer array of that class and make NEW pieces of it (through loop) and that's fine and all. I can also make another class with a similar array and even make NEW instances of that as well and initialize them, but when I try to access them, I have problems. </p>
  
  <p>This code <em>almost</em> works fine:</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  class testClass{
      public:
      int number;
  };
  
  class testPoint{
      public:
      testClass testInstance;
      testClass *testclassArray[5];
      void makeArray();
      void setToI();
  };
  
  void testPoint::makeArray(){
      for (int i = 0; i &lt; 5; i++){
          testclassArray[i] = new testClass;
      }
  }
  
  void testPoint::setToI(){
      for (int i = 0; i &lt; 5; i++){
          (*testclassArray[i]).number = i;
      }
  }
  
  int main(void){
      testPoint firstTestPoint;
      firstTestPoint.makeArray();
      firstTestPoint.setToI();
  //  EXCEPT FOR THIS LINE this is where I have problems
      cout &lt;&lt; firstTestPoint.(*testclassArray[0]).number &lt;&lt; endl;
      return 0;
  }
  </code></pre>
  
  <p>I know this should work becuase this works</p>
  
  <pre><code>int main(void){
      testPoint firstInstance;
      firstInstance.testInstance.number = 3;
      cout &lt;&lt; firstInstance.testInstance.number &lt;&lt; endl;
      // and this works
      return 0;
  }
  </code></pre>
  
  <p>and this works</p>
  
  <pre><code>int main(void){
      testClass *testPointer[5];
      for (int i = 0; i &lt; 5; i++){
          testPointer[i] = new testClass;
          (*testPointer[i]).number = i; 
      }
      cout &lt;&lt; (*testPointer[0]).number &lt;&lt; endl; 
      return 0; 
  }
  </code></pre>
  
  <p>so why can't I access the members on the cout function the same way? </p>