title: vector compiler error for different variable type
body: <p>The goal of this assignment for my class is to ask the user for how many students are in the class.
  Using the Vector library create a vector of Strings to hold the students names.
  Create a vector of type double to hold a students grade average.</p>
  <p>I have a couple two compiler errors that are preventing my code from running. Line 73 &amp; 83. The following errors I am given:</p>
  <pre><code>main.cpp: In function ‘void add_student()’: main.cpp:73:11: error: request for member ‘push_back’ in ‘grade’, which is of non-class type ‘double’
  73 |     grade.push_back(grade);
     |           ^~~~~~~~~
  
  main.cpp: In function ‘void remove_student()’: main.cpp:83:23: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector&lt;std::__cxx11::basic_string&lt;char&gt; &gt;::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
  83 |     for (int i = 0; i &lt; students.size(); i++)
     |                     ~~^~~~~~~~~~~~~~~~~**
  </code></pre>
  <p>Any help would be much appreciated. Below is my entire code</p>
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;vector&gt;
  #include &lt;iomanip&gt;
  using namespace std;
  vector&lt;string&gt; students;
  vector&lt;double&gt; grade;
  void add_student();
  void remove_student();
  void menu();
  void print_summary();
  
  int main()
  {
      int numStudent;
      char menuSelection; 
  
      cout &lt;&lt; &quot;Welcome to the Student roaster!&quot; &lt;&lt; endl;
      cout &lt;&lt; &quot;How many students are in your class?:&quot; &lt;&lt; endl;
      cin &gt;&gt; numStudent;
      for (int i = 0; i &lt; numStudent; i++)
      {
          add_student();
      }
      cout &lt;&lt; &quot;Thank you for entering class information!&quot; &lt;&lt; endl;
      
  
      //calls menu for the user
      menu();
  
  
      while (1)
      {
          cout &lt;&lt; &quot;selection:&quot; &lt;&lt; endl;
          cin &gt;&gt; menuSelection;
          if (menuSelection == 'a')
          {
              add_student();
          }
          else if (menuSelection == 'r')
          {
              remove_student();
          }
          else if (menuSelection == 'p')
          {
              print_summary();
          }
          else if (menuSelection == 'm')
          {
              menu();
          }
          else if (menuSelection == 'q')
              break;
          else
              cout &lt;&lt; &quot;Not a valid selection&quot; &lt;&lt; endl;
      }
      return 0;
  }
  void add_student()
  {
      string firstName, lastName;
      double grade;
  
      //ask for student info
      cout &lt;&lt; &quot;Please enter student (Fisrt Last Grade) info: &quot; &lt;&lt; endl;
      cin &gt;&gt; firstName &gt;&gt; lastName &gt;&gt; grade;
  
      firstName += &quot; &quot;;
      firstName += lastName;
  
      //inserts new student
      students.push_back(firstName); 
      grade.push_back(grade);
  }
  void remove_student()
  {
      string first, last;
      cout &lt;&lt; &quot;Enter the student (First Last) to remove :\n&quot;;
      cin &gt;&gt; first &gt;&gt; last;
      first += &quot; &quot;;
      first += last;
      int loc = 0;
      for (int i = 0; i &lt; students.size(); i++)
      {
          if (students[i] == first)
          { // finding the location to erase
              loc = i;
              break;
          }
      }
      students.erase(students.begin() + loc); //removing using erase function
      grade.erase(grade.begin() + loc);
  }
  void menu()
  {
      cout &lt;&lt; &quot;Please choose one of the following options:\n&quot;;
      cout &lt;&lt; &quot;a: add a student\n&quot;;
      cout &lt;&lt; &quot;r: remove a student\n&quot;;
      cout &lt;&lt; &quot;p: print the class summary\n&quot;;
      cout &lt;&lt; &quot;m: print menu\n&quot;;
      cout &lt;&lt; &quot;q: quit program\n&quot;;
  }
  void print_summary()
  {
      cout &lt;&lt; &quot;class summary&quot; &lt;&lt; endl;
      cout &lt;&lt; &quot;--------------------------------&quot; &lt;&lt; endl;
      cout &lt;&lt; &quot;Name&quot; &lt;&lt; setw(20) &lt;&lt; &quot;Grade&quot; &lt;&lt; endl;
      cout &lt;&lt; &quot;-------&quot; &lt;&lt; setw(20) &lt;&lt; &quot;--------&quot; &lt;&lt; endl;
      int n = students.size();
      double total = 0;
  
      //cycles through each student
      for (int i = 0; i &lt; n; i++)
      {
          int temp = students[i].size();
          int loc = 20 - temp;
          cout &lt;&lt; students[i] &lt;&lt; setw(loc) &lt;&lt; grade[i] &lt;&lt; endl;
          total += grade[i];
      }
      cout &lt;&lt; &quot;Number of students: &quot; &lt;&lt; endl;
      cout &lt;&lt; &quot;------------------&quot; &lt;&lt;endl;
      cout &lt;&lt; n &lt;&lt; &quot; &quot; &lt;&lt; endl;
      total = (total) / n;
      cout &lt;&lt; &quot;Average Grade: &quot; &lt;&lt; endl;
      cout &lt;&lt; &quot;--------------&quot; &lt;&lt; endl;
  
      //limits the deciaml places to 2
      cout &lt;&lt; fixed &lt;&lt; setprecision(2) &lt;&lt; total &lt;&lt; &quot; &quot; &lt;&lt; endl;
  }
  </code></pre>