title: Return entire Array
body: <pre><code>#include &lt;cstdlib&gt;
  #include &lt;iostream&gt;
  #include &lt;string&gt;
  
  using namespace std;
  
  class Student
  {
  private:
      string name;
      int year;
      string semester;
      int AmtClass;
      string *CName;
      static string cohort[4];
  
  public:
      Student();
      Student(int AmtClass);
      Student(Student &amp;);
  
      void setCourses(string courses[], int n);
      void setName(string name);
      void setYear(int year);
      void setSemester(string semester);
  
      string getName();
      int getYear();
      string getSemester();
      int getAmtClass();
      string getCohort();
      string getCNames();
    //  ~Student();
  };
  
  string Student::cohort[4] = "";
  
  
  Student::Student()
  {
      name = "";
      year = 0;
      semester = "";
      AmtClass = 0;
  }
  
  //I am trying to create a dynamically allocated array of strings
  Student::Student(int amount)
  {
      AmtClass = amount;
  
      CName = new string[AmtClass];
  }
  
  void Student::setCourses(string courses[], int n)
  {
      CName[n] = courses[n];
  }
  
  Student::Student(Student &amp;obj)
  {
      *this = obj;
  }
  
  void Student::setName(string Name)
  {
      name = Name;
  }
  
  void Student::setYear(int Year)
  {
      year = Year;
  
      switch(year)
      {
      case 1:
          cohort[0] = "Freshman";
          break;
      case 2:
          cohort[1] = "Sophomore";
          break;
      case 3:
          cohort[2] = "Junior";
          break;
      case 4:
          cohort[3] = "Senior";
          break;
      }
  }
  
  void Student::setSemester(string Semester)
  {
      semester = Semester;
  }
  
  string Student::getName()
  {
      return name;
  }
  
  int Student::getYear()
  {
      return year;
  }
  
  string Student::getSemester()
  {
      return semester;
  }
  
  int Student::getAmtClass()
  {
      return AmtClass;
  }
  
  string Student::getCohort()
  {
      year -= 1;
      return cohort[year];
  }
  
  //Returns only the first course name i entered, i want to return all
  string Student::getCNames()
  {
      return *CName;
  }
  
  void readStudentData(Student &amp;);
  void printStudentData(Student);
  
  int main()
  {
      int amount;
      cout &lt;&lt; "How many courses are you currently taking? ";
      cin &gt;&gt; amount;
  
      Student kid(amount);
  
      readStudentData(kid);
      printStudentData(kid);
  }
  
  void readStudentData(Student &amp;kid)
  {
      cin.ignore(10000, '\n');
  
      int amount = kid.getAmtClass();
      string name = "";
      string semester = "";
      int year = 0;
      string *pName = new string[amount];
  
      cout &lt;&lt; "What is your full name? ";
      getline(cin,name);
      kid.setName(name);
  
      cout &lt;&lt; "Type in 1 for Freshman, 2 for Sophomore, 3 for Junior or 4 for Senior.";
      cout &lt;&lt; "\nWhat year are you? ";
      cin &gt;&gt; year;
      while(cin)
      {   if(year &gt;=1  &amp;&amp; year &lt;= 4)
          {
              kid.setYear(year);
              break;
          }
          else
          {
              cout &lt;&lt; "Number must be between 1 and 4 Please try again." &lt;&lt; endl;
              year = 0;
              cin &gt;&gt; year;
          }
      }
  
      cin.ignore();
      cout &lt;&lt; "What is your current semester? ";
      getline(cin,semester);
      kid.setSemester(semester);
  
      cout &lt;&lt; "Please enter the name of all your courses." &lt;&lt; endl;
      for(int i = 0; i &lt; amount; i++)
      {
          cout &lt;&lt; "Course #" &lt;&lt; i+1 &lt;&lt; " : ";
          getline(cin,pName[i]);
          kid.setCourses(pName, i);
      }
  }
  
  void printStudentData(Student kid)
  {
      Student kid2 = kid;
      cout &lt;&lt; "\nHere is your information:" &lt;&lt; endl;
      cout &lt;&lt; "Name : " &lt;&lt; kid2.getName() &lt;&lt; endl;
      cout &lt;&lt; "Semester : " &lt;&lt; kid2.getSemester() &lt;&lt; endl;
      cout &lt;&lt; "Year : " &lt;&lt; kid2.getCohort() &lt;&lt; endl;
      for(int i = 0; i &lt; kid2.getAmtClass(); i++)
      {
          cout &lt;&lt; "Course #" &lt;&lt; i+1 &lt;&lt; " : " &lt;&lt; kid2.getCNames() &lt;&lt; endl;
      }
  }
  </code></pre>
  
  <p>So in this function I am trying to create a program that'll store information about a student. When I am taking the student's courses name and then printing them out later, I only end up with only the first course name that was entered in. I am trying to print all of the courses name the user has entered. I believe the problem is within the accessor function.</p>
  
  <p>Here are my results </p>
  
  <pre><code>How many courses are you currently taking? 2
  What is your full name? Testing Name
  Type in 1 for Freshman, 2 for Sophomore, 3 for Junior or 4 for Senior.
  What year are you? 4
  What is your current semester? Spring 2014
  Please enter the name of all your courses.
  Course #1 : C++
  Course #2 : Adv C++
  
  Here is your information:
  Name : Testing Name
  Semester : Spring 2014
  Year : Senior
  Course #1 : C++
  Course #2 : C++
  </code></pre>