how to call the function for an array of classes c++
<p>I created a class in C++ called Commands (file name commands.cpp). </p>

<p>I've taken that and put it into a command array (file name test.cpp).</p>

<p>What I would like to know is how to call the functions that are within the Commands class.</p>

<p>for example I have a function within the Commands class
  called</p>

<pre><code>     void command::init(char data[]) 
      {
        //detail
       }
</code></pre>

<p>and what i have tried to do to call the function is</p>

<p><em><strong>EDIT</em></strong> </p>

<pre><code>  Class test{
     int CmdCount;     // number of commands in the array
     int MaxCmds;      // max amount of commands allowed
     command* cmds;
  Public:
     int get_command_count() const{
          return CmdCount;
     }

     int readfile(const char fname[]){
          char line[161];

          FILE* fp;
          fp = fopen(fname, "r");

          if(fp){
               for(int i = 0; 1 == fscanf(fp, "%160[^\n]\n", line; i++){
                     cmds[get_command_count()].init(line);
                     CmdCount += 1;
               }
          }
          fclose(fp);
     }
  };
</code></pre>

<p>I just want to know how to be able to call void command::init(char data[]).</p>

<p>Any suggestions?</p>

<p>thanks.</p>
