title: c++ array of type " class student"
body: <p>i have this c++ assignment....and iam having a bit of a problem since iam used more to c#
  i created a class student in order to create an array with different elements...the problem  is how can i see the array in the functions in the class part...inorder to fill it with students details and display it..here is the code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;array&gt;
  #include &lt;iomanip&gt;
  
  using namespace std;
  
  class student{
  private:
      int id, age;
          string fname, lname, cob;
          char s;
          int stdcount;
  public:
  
      void addstd();
      void searchstd(int n);
      void displayinfo();
      void deletestd(int n);
      void displayrange();
      void modifyinfo(int n);
  };
  
  void student::addstd()
  {
      cout&lt;&lt;"Enter ID Number"&lt;&lt;endl;
      cin&gt;&gt;id;
      cout&lt;&lt;"Enter First Name"&lt;&lt;endl;
      cin&gt;&gt;fname;
      cout&lt;&lt;"Enter last Name"&lt;&lt;endl;
      cin&gt;&gt;lname;
      cout&lt;&lt;"Enter age"&lt;&lt;endl;
      cin&gt;&gt;age;
      cout&lt;&lt;"Enter student's Sex(F or M) "&lt;&lt;endl;
      cin&gt;&gt;s;
      cout&lt;&lt;"Enter Country of birth"&lt;&lt;endl;
      cin&gt;&gt;cob;
  }
  void student::displayinfo()
  {
      for(int i=0;i&lt;100;i++)
      {
          cout&lt;&lt;ar[i];
      }
  }
  void student::searchstd(int m)
  {
  }
  
  
  void main()
  {
      student s;
      student std[100];
      int choice;
      do{
  
      cout &lt;&lt; "-----------Menu------------" &lt;&lt; endl;
          cout &lt;&lt; "  1. Add a student " &lt;&lt; endl;
          cout &lt;&lt; "  2. Search for student by ID " &lt;&lt; endl;
          cout &lt;&lt; "  3. Display all students information   " &lt;&lt; endl;
          cout &lt;&lt; "  4. Remove a students  " &lt;&lt; endl;
          cout &lt;&lt; "  5. Display students aged between 34 - 50  " &lt;&lt; endl;
          cout &lt;&lt; "  6. Modify a student's information         " &lt;&lt; endl;
          cout &lt;&lt; "  7. Exit         " &lt;&lt; endl;
          cout &lt;&lt; "  Enter your choice 1, 2, 3, 4 ,5,6,7   " &lt;&lt; endl;
      cin&gt;&gt;choice;
      switch(choice) {
          case 1:
              for(int i=0;i&lt;3;i++)
              {
                  std[i].addstd();
              }
             break;
          case 2:
              int numid;
              cout &lt;&lt;"enter id "&lt;&lt;endl;
              cin&gt;&gt;numid;
              s.searchstd(numid);
             break;
          case 3:
             break;
          case 4:
              break;
          case 5:
             break;
          case 6:
             break;
          default:
             cout &lt;&lt; "Please enter 1, 2, 3, 4, 5, 6 or 7 : " &lt;&lt; endl &lt;&lt; endl;
      }
  
      }while(choice!=7);
  
  }
  </code></pre>