title: How to return a struct from a function in C++?
body: <p>I've tried on a few different forums and can't seem to get a straight answer, how can I make this function return the struct? If I try 'return newStudent;' I get the error 'No suitable user-defined conversion from studentType to studentType exists.'</p>
  
  <pre><code>// Input function
  studentType newStudent()
  {   
      struct studentType
      {
          string studentID;
          string firstName;
          string lastName;
          string subjectName;
          string courseGrade;
  
          int arrayMarks[4];
  
          double avgMarks;
  
      } newStudent;
  
      cout &lt;&lt; "\nPlease enter student information:\n";
  
      cout &lt;&lt; "\nFirst Name: ";
      cin &gt;&gt; newStudent.firstName;
  
      cout &lt;&lt; "\nLast Name: ";
      cin &gt;&gt; newStudent.lastName;
  
      cout &lt;&lt; "\nStudent ID: ";
      cin &gt;&gt; newStudent.studentID;
  
      cout &lt;&lt; "\nSubject Name: ";
      cin &gt;&gt; newStudent.subjectName;
  
      for (int i = 0; i &lt; NO_OF_TEST; i++)
      {   cout &lt;&lt; "\nTest " &lt;&lt; i+1 &lt;&lt; " mark: ";
          cin &gt;&gt; newStudent.arrayMarks[i];
      }
  
      newStudent.avgMarks = calculate_avg(newStudent.arrayMarks,NO_OF_TEST );
      newStudent.courseGrade = calculate_grade (newStudent.avgMarks);
  
  }
  </code></pre>