title: C++ Constructor and Destructor
body: <p>I'm getting some errors when compiling my program. They relate to the constructor and destructor of my class Instruction.</p>
  
  <p>Errors are:</p>
  
  <pre><code>/tmp/ccSWO7VW.o: In function `Instruction::Instruction(std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, int)':
  ale.c:(.text+0x241): undefined reference to `vtable for Instruction'
  /tmp/ccSWO7VW.o: In function `Instruction::Instruction(std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, int)':
  ale.c:(.text+0x2ab): undefined reference to `vtable for Instruction'
  /tmp/ccSWO7VW.o: In function `Instruction::~Instruction()':
  ale.c:(.text+0x315): undefined reference to `vtable for Instruction'
  /tmp/ccSWO7VW.o: In function `Instruction::~Instruction()':
  ale.c:(.text+0x38d): undefined reference to `vtable for Instruction'
  collect2: ld returned 1 exit status
  </code></pre>
  
  <p>Here is my code:</p>
  
  <pre><code>//classses.h
  
  #include &lt;iostream&gt;
  #include &lt;string&gt;
  using namespace std;
  
  class Instruction{
  
    protected:
      string name;
      int value;
  
    public:
      Instruction(string _name, int _value);
      ~Instruction();
      void setName(string _name);
      void setValue(int _value);
      string getName();
      int getValue();
      virtual void execute();
  };
  
  //constructor
  Instruction::Instruction(string _name, int _value){
      name = _name;
      value = _value;
  }
  //destructor
  Instruction::~Instruction(){
      name = "";
      value = 0;
  }
  void Instruction::setName(string _name){
       name = _name;
  }
  
  void Instruction::setValue(int _value){
      value = _value;
  }
  
  string Instruction::getName(){
         return name;
  }
  
  int Instruction::getValue(){
      return value;
  }
  </code></pre>
  
  <p>/////////////////////////////////////////////////////////////////////</p>
  
  <pre><code>//ale.cpp
  
      #include "headers.h"
      #include "functions.h"
      #include "classes.h"
      #include &lt;list&gt;
  
  
      using namespace std;
  
      int main(){
  
      return 0;
      }
  </code></pre>