title: What are the unresolved externals?
body: <p>I have looked up my question to no avail so I am here specifically to ask. When I run my code that takes a part and looks into a file of parts, it's part class, how many of that part there is, and how much it costs, it is supposed to tell me where it is in the file and if it isn't, to add it into the file. With the help of my professor, I corrected a lot of my errors, but I keep getting the unresolved external errors. Five to be exact. I don't really understand what this means. Here is the code and errors:</p>
  
  <pre><code>#include &lt;iostream&gt; 
  #include &lt;fstream&gt;
  #include &lt;iomanip&gt;
  #include &lt;vector&gt;
  #include &lt;fstream&gt;
  #include &lt;string&gt;
  #include &lt;algorithm&gt;
  
  using namespace std;
  
  // Sorts vectors (Calls swapper) 
  void sort(vector&lt;string&gt;&amp; part_number, vector&lt;char&gt;&amp; part_class, vector&lt;int&gt;&amp;ohb, vector&lt;double&gt;&amp; cost);
  
  // Fills vectors
  bool get_data (vector &lt;string&gt;&amp; part_number, vector &lt;char&gt;&amp; part_class, vector&lt;int&gt;&amp; part_ohb, vector &lt;double&gt;&amp; part_cost);
  
  // Does a binary search  
  int bin_search(string key, const vector&lt;string&gt;&amp; part_number);
  
  // Asks user for a part number to search for
  void get_target();
  
  // Gets remaining info to add a part number
  void get_more_data(char&amp; class_in,int&amp; part_ohb_in,double&amp; part_cost_in);
  
  // Inserts part number data into vectors into the proper location (code for this given below)
  void insert_data (vector &lt;string&gt;&amp; part_number, vector &lt;char&gt;&amp; part_class, vector &lt;int&gt;&amp; part_ohb, vector &lt;double&gt;&amp; part_cost, string part_in, char class_in, int part_ohb_in, double part_cost_in);
  
  // Displays info on part number
  void display (const vector &lt;string&gt;&amp; part_number, const vector &lt;char&gt;&amp; part_class, const vector &lt;int&gt;&amp; part_ohb, const vector &lt;double&gt;&amp; part_cost, int finder);
  
  // Prints search stats
  void print_stats(int searches, int good, int bad);
  
  // Writes out file
  void put_data (const vector &lt;string&gt;&amp; part_number, const vector &lt;char&gt;&amp; part_class, const vector &lt;int&gt;&amp; part_ohb, const vector &lt;double&gt;&amp; part_cost);
  
  // Templated swap function.  Swaps two items in a vector of any type
  template &lt;class CType&gt; void swapper (CType&amp; a, CType &amp; b);
  
  
  int main() {
      vector &lt;string&gt; part_number;
      vector &lt;char&gt; part_class;
      vector &lt;int&gt; part_ohb;
      vector &lt;double&gt; part_cost;
      string key, part_in;
      int part_ohb_in, searches, good, bad, finder;
      char class_in, response;
      double part_cost_in;
  
      do {
          get_target();
          searches++;
  
          get_data (part_number, part_class, part_ohb, part_cost);
          sort(part_number, part_class, part_ohb, part_cost);
          finder = bin_search(key, part_number);
  
          if (finder == -1) {
             cout &lt;&lt; part_in &lt;&lt; "not found!\n";
             get_more_data(class_in, part_ohb_in, part_cost_in);
  
             cout &lt;&lt; "Adding part into library...\n";
             bad++;
             insert_data (part_number, part_class, part_ohb, part_cost, part_in, class_in, part_ohb_in, part_cost_in);
             sort(part_number, part_class, part_ohb, part_cost);
          }
          else {
             display (part_number, part_class, part_ohb, part_cost, finder);
             good++;
          }  
  
          cout &lt;&lt; "Would you like to search again?" &lt;&lt; endl;
      } while (toupper(response) != 'Y');
  
      print_stats(searches, good, bad);
      put_data (part_number, part_class, part_ohb, part_cost);
  
      return 0;
  }
  
  void sort(vector&lt;string&gt;&amp; part_number, vector&lt;char&gt;&amp; part_class, vector&lt;int&gt;&amp; part_ohb, vector&lt;double&gt;&amp; part_cost) {
      int i, j, increment;
      string temp_pn;
      char temp_pc;
      int temp_ohb;
      double temp_cost;
      increment = 3;
  
      while (increment &gt; 0) {
          for (i=0; i &lt; part_number.size(); i++) {
              j = i;
              swapper(temp_pn, part_number[i]);
              swapper(temp_pc, part_class[i]);
              swapper(temp_ohb, part_ohb[i]);
              swapper(temp_cost, part_cost[i]);
  
              while ((j &gt;= increment) &amp;&amp; (part_number[j-increment] &gt; temp_pn)) {
                  swapper(part_number[j], part_number[j - increment]);
                  swapper(part_class[j], part_class[j - increment]);
                  swapper(part_ohb[j], part_ohb[j - increment]);
                  swapper(part_cost[j], part_cost[j - increment]);
                  j = j - increment;
              }
  
              swapper( part_number[j], temp_pn);
              swapper( part_class[j],  temp_pc);
              swapper( part_ohb[j], temp_ohb);
              swapper( part_cost[j], temp_cost);
          }
  
          if (increment/2 != 0) {
              increment = increment/2;
          }
          else if (increment == 1) {
              increment = 0;
          }
          else {
              increment = 1;
          }
      }
  }
  
  bool get_data (vector &lt;string&gt;&amp; part_number, vector &lt;char&gt;&amp; part_class, vector &lt;int&gt;&amp; part_ohb, vector &lt;double&gt;&amp; part_cost) {
      bool OK = true;
      string partIn;
      int ohbIn;
      char classIn;
      double costIn;
  
      ifstream myFile;
      myFile.open("parts.txt");
      if (myFile.fail()) {
          OK = false;
      }
      else {
          while(myFile &gt;&gt; partIn &gt;&gt; classIn &gt;&gt; ohbIn &gt;&gt; costIn) {
              part_number.push_back(partIn);
              part_class.push_back(classIn);
              part_ohb.push_back(ohbIn);
              part_cost.push_back(costIn);
  
              myFile.close();
          }
      }
  
      return OK;
  }
  
  int bin_search(string key, const vector&lt;string&gt;&amp; part_number) {
      bool found = false;    
      int first, mid, last, return_val;
      first = 0;
      last = part_number.size()-1;
  
      while ((first &lt;= last) &amp;&amp; (!found)) { 
          mid = (first + last) / 2;
  
          if (key == part_number[mid]) {
              found = true;
          }
          else {
              if (key &lt; part_number[mid]) {
                  last = mid - 1;
              }
              else {
                  first = mid + 1;
              }
          }
      }
  
      if (found) {
          return_val = mid;
      }
      else { 
          return_val = -1;
      }
  
      return return_val;
  }
  
  void get_target(string&amp; key) {
      cout &lt;&lt; "What part number should I search for?" &lt;&lt; endl;
      cin &gt;&gt; key;
  }
  
  void get_more_data(char&amp; class_in, int&amp; part_ohb_in, double&amp; part_cost_in) {
      cout &lt;&lt; "Please add in the part class, how many of them there are, and the cost per part: ";
      cin &gt;&gt; class_in &gt;&gt; part_ohb_in &gt;&gt; part_cost_in;
  }
  
  void insert_data (vector &lt;string&gt;&amp; part_number, vector &lt;char&gt;&amp; part_class, vector &lt;int&gt;&amp; part_ohb, vector &lt;double&gt;&amp; part_cost, string part_in, char class_in, int part_ohb_in, double part_cost_in) {
      part_number.push_back(part_in);
      part_class.push_back(class_in);
      part_ohb.push_back(part_ohb_in);
      part_cost.push_back(part_cost_in);
  }
  
  void display (const vector &lt;string&gt;&amp; part_number, const vector &lt;char&gt;&amp; part_class, const vector &lt;int&gt;&amp; part_ohb, const vector &lt;double&gt;&amp; part_cost, int finder) {
      int total = part_ohb[finder] * part_cost[finder];
  
      cout &lt;&lt; "There are " &lt;&lt; part_ohb[finder] &lt;&lt; " of Part Number " &lt;&lt; part_number[finder] &lt;&lt; " in inventory. It is a class " &lt;&lt; part_class[finder] &lt;&lt; " part. The cost is " &lt;&lt; part_cost[finder] &lt;&lt; ". The value of that inventory is " &lt;&lt; total &lt;&lt; ".\n";
  }
  
  void print_stats(int searches, int good, int bad) {
      cout &lt;&lt; "You made " &lt;&lt; searches &lt;&lt; " searches with " &lt;&lt; good &lt;&lt; " successful searches and " &lt;&lt; bad &lt;&lt; " bad searches.\n";
  }
  
  void put_data (const vector &lt;string&gt;&amp; part_number, const vector &lt;char&gt;&amp; part_class, const vector &lt;int&gt;&amp; part_ohb, const vector &lt;double&gt;&amp; part_cost) {
      // for loop for displaying
      ofstream myfile;
      myfile.open ("parts.txt");
  
      for (int i = 0; i &lt; part_number.size(); i++) {
          myfile &lt;&lt; part_number[i] &lt;&lt; "  " &lt;&lt; part_class[i] &lt;&lt; "  " &lt;&lt; part_ohb[i] &lt;&lt; "  " &lt;&lt; part_cost[i] &lt;&lt; endl;
      }
  
      myfile.close();
  }
  </code></pre>
  
  <p>Errors: </p>
  
  <pre><code>1&gt;Project3Source.obj : error LNK2019: unresolved external symbol "void __cdecl get_target(void)" (?get_target@@YAXXZ) referenced in function _main
  1&gt;Project3Source.obj : error LNK2019: unresolved external symbol "void __cdecl swapper&lt;class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt; &gt;(class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt; &amp;,class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt; &amp;)" (??$swapper@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@@YAXAAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@0@Z) referenced in function "void __cdecl sort(class std::vector&lt;class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt;,class std::allocator&lt;class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt; &gt; &gt; &amp;,class std::vector&lt;char,class std::allocator&lt;char&gt; &gt; &amp;,class std::vector&lt;int,class std::allocator&lt;int&gt; &gt; &amp;,class std::vector&lt;double,class std::allocator&lt;double&gt; &gt; &amp;)" (?sort@@YAXAAV?$vector@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@AAV?$vector@DV?$allocator@D@std@@@2@AAV?$vector@HV?$allocator@H@std@@@2@AAV?$vector@NV?$allocator@N@std@@@2@@Z)
  1&gt;Project3Source.obj : error LNK2019: unresolved external symbol "void __cdecl swapper&lt;char&gt;(char &amp;,char &amp;)" (??$swapper@D@@YAXAAD0@Z) referenced in function "void __cdecl sort(class std::vector&lt;class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt;,class std::allocator&lt;class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt; &gt; &gt; &amp;,class std::vector&lt;char,class std::allocator&lt;char&gt; &gt; &amp;,class std::vector&lt;int,class std::allocator&lt;int&gt; &gt; &amp;,class std::vector&lt;double,class std::allocator&lt;double&gt; &gt; &amp;)" (?sort@@YAXAAV?$vector@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@AAV?$vector@DV?$allocator@D@std@@@2@AAV?$vector@HV?$allocator@H@std@@@2@AAV?$vector@NV?$allocator@N@std@@@2@@Z)
  1&gt;Project3Source.obj : error LNK2019: unresolved external symbol "void __cdecl swapper&lt;int&gt;(int &amp;,int &amp;)" (??$swapper@H@@YAXAAH0@Z) referenced in function "void __cdecl sort(class std::vector&lt;class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt;,class std::allocator&lt;class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt; &gt; &gt; &amp;,class std::vector&lt;char,class std::allocator&lt;char&gt; &gt; &amp;,class std::vector&lt;int,class std::allocator&lt;int&gt; &gt; &amp;,class std::vector&lt;double,class std::allocator&lt;double&gt; &gt; &amp;)" (?sort@@YAXAAV?$vector@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@AAV?$vector@DV?$allocator@D@std@@@2@AAV?$vector@HV?$allocator@H@std@@@2@AAV?$vector@NV?$allocator@N@std@@@2@@Z)
  1&gt;Project3Source.obj : error LNK2019: unresolved external symbol "void __cdecl swapper&lt;double&gt;(double &amp;,double &amp;)" (??$swapper@N@@YAXAAN0@Z) referenced in function "void __cdecl sort(class std::vector&lt;class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt;,class std::allocator&lt;class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt; &gt; &gt; &amp;,class std::vector&lt;char,class std::allocator&lt;char&gt; &gt; &amp;,class std::vector&lt;int,class std::allocator&lt;int&gt; &gt; &amp;,class std::vector&lt;double,class std::allocator&lt;double&gt; &gt; &amp;)" (?sort@@YAXAAV?$vector@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@AAV?$vector@DV?$allocator@D@std@@@2@AAV?$vector@HV?$allocator@H@std@@@2@AAV?$vector@NV?$allocator@N@std@@@2@@Z)
  1&gt;C:\Users\Austin Julio\Desktop\CMPSC 121\Projects\Project 3\Debug\Project 3.exe : fatal error LNK1120: 5 unresolved externals
  </code></pre>