title: C++ : error LNK2019: unresolved external symbol
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix">What is an undefined reference/unresolved external symbol error and how do I fix it?</a>  </p>
  </blockquote>
  
  
  
  <p>So I have compared my issue to the vast library of problems that have spawned from this category on this site. I still have no clue as to why my compiler is complaining.</p>
  
  <p>So let me give a short briefing on what it is I want to do with my program. I am researching elevator algorithms. I want to implement priority queues using a binary heap.</p>
  
  <p>I have got the source code from mark allen wiess website. For the heaps.</p>
  
  <p>I am constructing my own reqnode class that represents the nodes of the binary tree.</p>
  
  <p>reqnode = request node. </p>
  
  <p>The scenario is: A user makes a request. I service the request. I am working with multiple requests. Thus I have to use a priority, on which user to satisfy first. </p>
  
  <p>This is my header file for my binary heap.</p>
  
  <pre><code>#include &lt;vector&gt;
  using namespace std;
  
  BinaryHeap class.
  
  CONSTRUCTION: with no parameters or vector containing items.
  
  template &lt;class Comparable&gt;
  class BinaryHeap
  {
  public:
  BinaryHeap( );
  BinaryHeap( const vector&lt;int&gt; &amp; v );
  
  bool isEmpty( ) const;
  const Comparable &amp; findMin( ) const;
  
  void insert( const Comparable &amp; x);
  void deleteMin( );
  void deleteMin( Comparable &amp; minItem );
  void makeEmpty( );
  
  private:
  int theSize;  // Number of elements in heap
  vector&lt;Comparable&gt; Array;    // The heap Array
  
  void buildHeap( );
  void percolateDown( int hole );
  };
  </code></pre>
  
  <p>These are the functions defined for my binary heap.</p>
  
  <pre><code>#include "binaryHeap.h"
  using namespace std;
  
  // Construct the binary heap.
  template &lt;class Comparable&gt;
  BinaryHeap&lt;Comparable&gt;::BinaryHeap( )
  : Array( 11 ), theSize( 0 )
  {
  }
  
  // Insert item x into the priority queue, maintaining heap order.
  // Duplicates are allowed.
  
  
  template &lt;class Comparable&gt;
  void BinaryHeap&lt;Comparable&gt;::insert( const Comparable &amp; x) 
  {
  Array[ 0 ] = x;   // initialize sentinel
  if( theSize + 1 == Array.size( ) )
      Array.resize( Array.size( ) * 2 + 1 );
  
    // Percolate up
  int hole = ++theSize;
  for( ; x &lt; Array[ hole / 2 ]; hole /= 2 )
      Array[ hole ] = Array[ hole / 2 ];
  Array[ hole ] = x;
  }
  
  // Find the smallest item in the priority queue.
  // Return the smallest item, or throw UnderflowException if empty.
  template &lt;class Comparable&gt;
  const Comparable &amp; BinaryHeap&lt;Comparable&gt;::findMin( ) const
  {
  if( isEmpty( ) ){
      cout &lt;&lt; "heap empty" &lt;&lt; endl; //throw UnderflowException( );
      break;
  }
  return Array[ 1 ];
  }
  
  // Remove the smallest item from the priority queue.
  // Throw UnderflowException if empty.
  template &lt;class Comparable&gt;
  void BinaryHeap&lt;Comparable&gt;::deleteMin( )
  {
  if( isEmpty( ) ){
      cout &lt;&lt; "heap empty" &lt;&lt; endl; //throw UnderflowException( );
      break;
  }
  
  Array[ 1 ] = Array[ theSize-- ];
  percolateDown( 1 );
  }
  
  // Remove the smallest item from the priority queue
  // and place it in minItem. Throw UnderflowException if empty.
  template &lt;class Comparable&gt;
  void BinaryHeap&lt;Comparable&gt;::deleteMin( Comparable &amp; minItem )
  {
  minItem = findMin( );
  Array[ 1 ] = Array[ theSize-- ];
  percolateDown( 1 );
  }
  
  // Establish heap-order property from an arbitrary
  // arrangement of items. Runs in linear time.
  template &lt;class Comparable&gt;
  void BinaryHeap&lt;Comparable&gt;::buildHeap( )
  {
  for( int i = theSize / 2; i &gt; 0; i-- )
      percolateDown( i );
  }
  
  // Test if the priority queue is logically empty.
  // Return true if empty, false otherwise.
  template &lt;class Comparable&gt;
  bool BinaryHeap&lt;Comparable&gt;::isEmpty( ) const
  {
  return theSize == 0;
  }
  
  // Make the priority queue logically empty.
  template &lt;class Comparable&gt;
  void BinaryHeap&lt;Comparable&gt;::makeEmpty( )
  {
  theSize = 0;
  }
  
  // Internal method to percolate down in the heap.
  // hole is the index at which the percolate begins.
  template &lt;class Comparable&gt;
  void BinaryHeap&lt;Comparable&gt;::percolateDown( int hole )
  {
  int child;
  Comparable tmp = Array[ hole ];
  
  for( ; hole * 2 &lt;= theSize; hole = child )
  {
      child = hole * 2;
      if( child != theSize &amp;&amp; Array[ child + 1 ] &lt; Array[ child ] )
          child++;
      if( Array[ child ] &lt; tmp )
          Array[ hole ] = Array[ child ];
      else
          break;
  }
  Array[ hole ] = tmp;
  }
  </code></pre>
  
  <p>This is my header file for reQnode</p>
  
  <pre><code>class reqNode//create a node that takes in several properties.
  {
  public:
  reqNode(){  //default constructor
  static priority = start = destination = timestamp = start_time = finish_time = -1;
  }
  
  reqNode(const reqNode &amp;copy){       //copy constructor
  priority = copy.priority;
  start = copy.start;
  destination = copy.destination;
  timestamp = copy.timestamp;
  start_time = copy.start_time;
  finish_time = copy.finish_time;
  }
  
  reqNode &amp; operator=(const reqNode &amp; copy){
  priority = copy.priority;
  start = copy.start;
  destination = copy.destination;
  timestamp = copy.timestamp;
  start_time = copy.start_time;
  finish_time = copy.finish_time;
  
  return *this;
  }
  
  int priority, start, destination, timestamp, start_time, finish_time;
  bool direction;
  
  bool operator&lt;(reqNode &amp;rhs){
  if(this-&gt;priority &lt; rhs.priority)
  return true;
  else
  return false;
  }
  
  void setPriority(int x){
  priority=x;
  }
  };
  </code></pre>
  
  <p>This is my driver implementation</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;fstream&gt;
  #include &lt;string&gt;
  #include "binaryHeap.h"
  #include "reqnode.h"
  
  #include &lt;algorithm&gt;
  using namespace std;
  
  void setNode(reqNode nizzode, int priority)
  {
  nizzode.priority = priority;
  }
  
  
  int main()
  {
  int numItems = 10000;
  BinaryHeap&lt;reqNode&gt; h;
  int i = 37;
  reqNode x;
  reqNode * temp;
  
  for( i = 37; i != 0; i = ( i + 37 ) % numItems ){
  temp = new reqNode;
  temp-&gt;setPriority(i);
  h.insert( *temp );
  }
  
  for( i = 1; i &lt; numItems; i++ )
  {
  h.deleteMin( x );
  if( x.priority != i )
  cout &lt;&lt; "Oops! " &lt;&lt; i &lt;&lt; endl;
  }
  
  for( i = 37; i != 0; i = ( i + 37 ) % numItems ){
  temp = new reqNode;
  temp-&gt;setPriority(i);
  h.insert( *temp );
  }
  
  temp = new reqNode;
  temp-&gt;setPriority(i);
  h.insert( *temp );
  
  
  return 0;
  }
  </code></pre>
  
  <p>Finally, These are the errors that haunt me!</p>
  
  <pre><code>1&gt;Driver2.obj : error LNK2019: unresolved external symbol "public: void __thiscall BinaryHeap&lt;class reqNode&gt;::deleteMin(class reqNode &amp;)" (?deleteMin@?$BinaryHeap@VreqNode@@@@QAEXAAVreqNode@@@Z) referenced in function _main
  1&gt;Driver2.obj : error LNK2019: unresolved external symbol "public: void __thiscall BinaryHeap&lt;class reqNode&gt;::insert(class reqNode const &amp;)" (?insert@?$BinaryHeap@VreqNode@@@@QAEXABVreqNode@@@Z) referenced in function _main
  1&gt;Driver2.obj : error LNK2019: unresolved external symbol "public: __thiscall BinaryHeap&lt;class reqNode&gt;::BinaryHeap&lt;class reqNode&gt;(void)" (??0?$BinaryHeap@VreqNode@@@@QAE@XZ) referenced in function _main
  1&gt;C:\Users\Aaron Artis\Documents\Visual Studio 2010\Projects\Elevator_Algo_Remix1\Debug\Elevator_Algo_Remix1.exe : fatal error LNK1120: 3 unresolved externals
  </code></pre>
  
  <p>I'm unsure of where to pinpoint this problem. I had a previous linker error. I resolved it. This one just seems like a doozy.</p>