title: Lnk2020 error for C++ program
body: <p>So what im trying to do is use an array of pointers to keep track of spawning bots and let them do battle by colliding.  This is done by using methods in an array of pointers but i keep getting a LNK2020 error when I build it</p>
  
  <p>This is the VBot.h File</p>
  
  <pre><code>class VBot
  {
  public:
  
  VBot( int startX, int startY, Panel ^ drawingPanel ) : 
    x(startX), y(startY), panel(drawingPanel), energy(100), image(NULL) { };
  
  
  virtual ~VBot() { };
  
  virtual void Move() = 0;
  
  virtual int EnergyToFightWith() = 0;
  
  bool IsDead() const { return energy &lt;= 0; }
  
  virtual void Show();
  
  bool CollidedWith ( VBot * b ) const;
  
    void DoBattleWith ( VBot * b );
  
  protected:
    int x, y;                           // Current position of the VBot
    gcroot&lt;Drawing::Bitmap ^&gt; image;    // Image displayed for the VBot
    gcroot&lt;Panel ^&gt; panel;              // Panel on which to show the VBot.
    int energy;                           
    VBot();
  };
  
  class CNNBot : public VBot
  {
  public:
  CNNBot( int startX, int startY, Panel ^ drawingPanel ):
  VBot(startX, startY, drawingPanel)
  {
      image = gcnew Drawing::Bitmap("HappyBot.bmp");
  }
  ~CNNBot(){};
  
  void Move();
  
  int EnergyToFightWith();
  bool IsDead() { return (VBot::IsDead()); }
  virtual void Show() { VBot::Show();}
  bool CollidedWith ( VBot * b ) { return VBot::CollidedWith(b);}
  void DoBattleWith ( VBot * b ){ VBot::DoBattleWith(b);}
  
  private:
  static const int MOVE_VAL = 55;
  static const int RIGHT_BOUND = 490;
  static const int DOWN = 40;
  static const int MAXY = 379;
  bool switcher;
  
  };
  </code></pre>
  
  <p>This is the VBot.cpp File</p>
  
  <pre><code>#include "stdafx.h"     
  
  #include "Vbot.h"
  
  void VBot::Show()
  { 
    Graphics ^ g = panel-&gt;CreateGraphics();
    g-&gt;DrawImageUnscaled( image, x, y );
    g-&gt;~Graphics();
   }
  
  
  bool VBot::CollidedWith ( VBot * b ) const
  {
   if (  b == NULL )
    return false;
  
  return   ( x + image-&gt;Width ) &gt;= b-&gt;x
    &amp;&amp; ( b-&gt;x + b-&gt;image-&gt;Width ) &gt;= x
    &amp;&amp; ( y + image-&gt;Height ) &gt;= b-&gt;y
    &amp;&amp; ( b-&gt;y + b-&gt;image-&gt;Height ) &gt;= y;
  
  }
  
  
  void VBot::DoBattleWith ( VBot * b )
  {
   int mine = EnergyToFightWith();
   int yours = b-&gt;EnergyToFightWith();
  if( mine == yours )
  {
   energy = energy - mine / 2;
   b-&gt;energy = b-&gt;energy - yours / 2;
  }
  void CNNBot::Move()
  {
  if (this-&gt;switcher)
  {
    this-&gt;x += MOVE_VAL;
    if( this-&gt;x &gt;= RIGHT_BOUND)
  {
      this-&gt;x = 0;
      this-&gt;y += DOWN;
      if(this-&gt;y &gt; MAXY)
      {
          this-&gt;switcher = false;
          this-&gt;y = MAXY;
      }
   }
  }
  else
  {
    this-&gt;x += MOVE_VAL;
    if( this-&gt;x &gt;= RIGHT_BOUND)
  {
      this-&gt;x = 0;
      this-&gt;y -= DOWN;
      if(this-&gt;y &lt; 0)
      {
          this-&gt;switcher = true;
          this-&gt;y = 0;
      }
   }
  }
  panel-&gt;Invalidate();
  }
  </code></pre>
  
  <p>This is the BotContainer.h</p>
  
  <pre><code>#include &lt;vcclr.h&gt;
  #include "VBot.h"
  #include "stdafx.h"
  #ifndef BOTCONTAINER_H
  #define BOTCONTAINER_H
  using namespace std;
  
  //------------------------------------------------------------------------------
  // This class is an array class that will contain pointers to bots that are spawned
      //
  class BotContainer
  {
  private:
  static const int MAXARRAY = 1000; //this is the max size of the array
  VBot * list[MAXARRAY]; //This is the array of pointers
  int count; // the variable that keeps track of the array
  
  public:
  //-------------------------------------------------------------------------------
  //this the constructor that sets count to zero
  //-------------------------------------------------------------------------------
  BotContainer(){ count = 0;}
  //--------------------------------------------------------------------------------
  //This method will check for a collision between the all possible combinations of 
  //two bots it is const
  //---------------------------------------------------------------------------------
  void checkCollisions() const;
  //---------------------------------------------------------------------------------
  //This method will destroy all dead bots in the array
  //---------------------------------------------------------------------------------
  
  void destroy();
  //----------------------------------------------------------------------------------
  //This method will take given bot pointer and add it to the list.
  //The Parameters are a pointer to a VBot called inBot.
  //This inBot will be added to the end of the array which will then increment count
  //Before adding it checks to make sure the array isn't full.
  //----------------------------------------------------------------------------------
  void add(VBot * inBot);
  void Add(CNNBot * inBot);
  //----------------------------------------------------------------------------------
  //This method will move all the elements in the array.
  //----------------------------------------------------------------------------------
  void moveAll();
  };
  #endif
  </code></pre>
  
  <p>This the BotContainer.cpp file</p>
  
  <pre><code>#include "stdafx.h"
  #include &lt;vcclr.h&gt;
  #include "BotContainer.h"
  //---------------------------------------------------------------------------------
  //This method will delete all the deat bots in the array from the highest indexed
  //dead bot.  If a bot is deleted then the method will shift all higher indexed elements
  // to one index less than its previous index
  //-------------------------------------------------------------------------------------
  void BotContainer::destroy()
  {
  for( int i = count - 1; i &lt;= 0; i--)
  {
      if ( list[i]-&gt;IsDead() == true )
      {
          int current = i; //index of the dead array
          delete list[i];
          for( int j = i + 1; j &lt; count; j++)
          {
              list[current] = list[j];
              current = j; // index of the next element above the one just shifted
          }
          count--;
      }
  }
  }
  //------------------------------------------------------------------------------------
  //This method will go throught the array calling move() for each bot in the array
  //-----------------------------------------------------------------------------------
  void BotContainer::moveAll()
  {
  for( int i = 0; i &lt; count; i++)
  {
      list[i]-&gt;Move();
  }
  }
  //-----------------------------------------------------------------------------------
  //This method checks for collisions between any 2 bots in the array making sure to not 
  //test (ivsi) or (ivsj) and also testing (jvsi).
  // This method is const therfore it doesn't change the array just tests it.
  //-----------------------------------------------------------------------------------
  void BotContainer::checkCollisions() const
  {
  for( int i = 0; i &lt; count; i++)
  {   
      if (list[i]-&gt;IsDead() != true)
      {
          for( int j = i + 1; j &lt; count; j++)
          {
              if(list[j]-&gt;IsDead() != true)
              {
                  if ( list[i]-&gt;CollidedWith(list[j])) 
                  {
                      list[i]-&gt;DoBattleWith(list[j]);
                  }
              }
  
          }
      }
  }
  }
  //--------------------------------------------------------------------------------
  //This method will add a pointer of a bot to the array checking first to make sure 
  //the array isn't full
  //--------------------------------------------------------------------------------
  void BotContainer::add(VBot * inBot)
  {
  if(this-&gt;count &lt;= MAXARRAY)
  { 
      list[count] = inBot;
      count++;
  }
  }
  void BotContainer::Add(CNNBot * inBot)
  {
  if(this-&gt;count &lt;= MAXARRAY)
  { 
      list[count] = inBot;
      count++;
  }
  }
  </code></pre>
  
  <p>And this is the Form.h file</p>
  
  <pre><code>#pragma once
  #include "stdafx.h"
  #include &lt;vcclr.h&gt;
  #include "BotContainer.h"
  
  namespace Prog3
  {
  
  using namespace System;
  using namespace System::ComponentModel;
  using namespace System::Collections;
  using namespace System::Windows::Forms;
  using namespace System::Data;
  using namespace System::Drawing;
  /// &lt;summary&gt;
  /// Summary for Form1
  /// &lt;/summary&gt;
  public ref class Form1 : public System::Windows::Forms::Form
  {
  public:
      Form1(void)
      {
          InitializeComponent();
          //
          //TODO: Add the constructor code here
          //
          x = 0;
          y = 0;
  
      }
  
  protected:
      /// &lt;summary&gt;
      /// Clean up any resources being used.
      /// &lt;/summary&gt;
      ~Form1()
      {
          if (components)
          {
              delete components;
          }
       }
  private: System::Windows::Forms::Panel^  pnlGameZone;
  private: System::Windows::Forms::ComboBox^  cmbSelect;
  
  protected: 
  
  
  
  private: System::Windows::Forms::Button^  btnBotSpawn;
  private: System::Windows::Forms::TrackBar^  trackBar1;
  private: System::Windows::Forms::Label^  label1;
  private: System::Windows::Forms::Label^  label2;
  private: System::Windows::Forms::Label^  label3;
  private: System::Windows::Forms::Label^  label4;
  private: System::ComponentModel::IContainer^  components;
  
  private:
      /// &lt;summary&gt;
      /// Required designer variable.
      /// &lt;/summary&gt;
  
  
      int x;
      int y;
      BotContainer  VList();
  private: System::Windows::Forms::Timer^  tmrspeed;
  
  private: System::Windows::Forms::NumericUpDown^  updownX;
  private: System::Windows::Forms::NumericUpDown^  updownY;
  
  
  
  #pragma region Windows Form Designer generated code
      /// &lt;summary&gt;
      /// Required method for Designer support - do not modify
      /// the contents of this method with the code editor.
      /// &lt;/summary&gt;
      void InitializeComponent(void)
      {
          this-&gt;components = (gcnew System::ComponentModel::Container());
          this-&gt;pnlGameZone = (gcnew System::Windows::Forms::Panel());
          this-&gt;cmbSelect = (gcnew System::Windows::Forms::ComboBox());
          this-&gt;btnBotSpawn = (gcnew System::Windows::Forms::Button());
          this-&gt;trackBar1 = (gcnew System::Windows::Forms::TrackBar());
          this-&gt;label1 = (gcnew System::Windows::Forms::Label());
          this-&gt;label2 = (gcnew System::Windows::Forms::Label());
          this-&gt;label3 = (gcnew System::Windows::Forms::Label());
          this-&gt;label4 = (gcnew System::Windows::Forms::Label());
          this-&gt;updownX = (gcnew System::Windows::Forms::NumericUpDown());
          this-&gt;updownY = (gcnew System::Windows::Forms::NumericUpDown());
          this-&gt;tmrspeed = (gcnew System::Windows::Forms::Timer(this-
    &gt;components));
          (cli::safe_cast&lt;System::ComponentModel::ISupportInitialize^  &gt;
    (this-&gt;trackBar1))-&gt;BeginInit();
          (cli::safe_cast&lt;System::ComponentModel::ISupportInitialize^  &gt;
   (this-&gt;updownY))-&gt;BeginInit();
          (cli::safe_cast&lt;System::ComponentModel::ISupportInitialize^  &gt;
   (this-&gt;updownY))-&gt;BeginInit();
          this-&gt;SuspendLayout();
          // 
          // pnlGameZone
          // 
          this-&gt;pnlGameZone-&gt;BackColor = 
    System::Drawing::SystemColors::Window;
          this-&gt;pnlGameZone-&gt;Location = System::Drawing::Point(53, 102);
          this-&gt;pnlGameZone-&gt;Name = L"pnlGameZone";
          this-&gt;pnlGameZone-&gt;Size = System::Drawing::Size(495, 379);
          this-&gt;pnlGameZone-&gt;TabIndex = 0;
          // 
          // cmbSelect
          // 
          this-&gt;cmbSelect-&gt;DropDownStyle =   
   System::Windows::Forms::ComboBoxStyle::DropDownList;
          this-&gt;cmbSelect-&gt;FormattingEnabled = true;
          this-&gt;cmbSelect-&gt;Items-&gt;AddRange(gcnew cli::array&lt; System::Object^  
       &gt;(3) {L"CNN Bot\t", L"MSNBC Bot", L"FOX NEWS Bot"});
          this-&gt;cmbSelect-&gt;Location = System::Drawing::Point(53, 52);
          this-&gt;cmbSelect-&gt;Name = L"cmbSelect";
          this-&gt;cmbSelect-&gt;Size = System::Drawing::Size(121, 21);
          this-&gt;cmbSelect-&gt;TabIndex = 1;
          // 
          // btnBotSpawn
          // 
          this-&gt;btnBotSpawn-&gt;Location = System::Drawing::Point(427, 48);
          this-&gt;btnBotSpawn-&gt;Name = L"btnBotSpawn";
          this-&gt;btnBotSpawn-&gt;Size = System::Drawing::Size(87, 23);
          this-&gt;btnBotSpawn-&gt;TabIndex = 4;
          this-&gt;btnBotSpawn-&gt;Text = L"Spawn a Bot";
          this-&gt;btnBotSpawn-&gt;UseVisualStyleBackColor = true;
          this-&gt;btnBotSpawn-&gt;Click += gcnew System::EventHandler(this, 
               &amp;Form1::tmrspeed_Tick);
          // 
          // trackBar1
          // 
          this-&gt;trackBar1-&gt;Location = System::Drawing::Point(552, 48);
          this-&gt;trackBar1-&gt;Maximum = 800;
          this-&gt;trackBar1-&gt;Minimum = 50;
          this-&gt;trackBar1-&gt;Name = L"trackBar1";
          this-&gt;trackBar1-&gt;Size = System::Drawing::Size(134, 45);
          this-&gt;trackBar1-&gt;TabIndex = 5;
          this-&gt;trackBar1-&gt;TickFrequency = 100;
          this-&gt;trackBar1-&gt;Value = 50;
          // 
          // label1
          // 
          this-&gt;label1-&gt;AutoSize = true;
          this-&gt;label1-&gt;Location = System::Drawing::Point(50, 34);
          this-&gt;label1-&gt;Name = L"label1";
          this-&gt;label1-&gt;Size = System::Drawing::Size(65, 13);
          this-&gt;label1-&gt;TabIndex = 6;
          this-&gt;label1-&gt;Text = L"Select a Bot";
          // 
          // label2
          // 
          this-&gt;label2-&gt;AutoSize = true;
          this-&gt;label2-&gt;Location = System::Drawing::Point(200, 35);
          this-&gt;label2-&gt;Name = L"label2";
          this-&gt;label2-&gt;Size = System::Drawing::Size(53, 13);
          this-&gt;label2-&gt;TabIndex = 7;
          this-&gt;label2-&gt;Text = L"Starting X";
          // 
          // label3
          // 
          this-&gt;label3-&gt;AutoSize = true;
          this-&gt;label3-&gt;Location = System::Drawing::Point(306, 35);
          this-&gt;label3-&gt;Name = L"label3";
          this-&gt;label3-&gt;Size = System::Drawing::Size(53, 13);
          this-&gt;label3-&gt;TabIndex = 8;
          this-&gt;label3-&gt;Text = L"Starting Y";
          // 
          // label4
          // 
          this-&gt;label4-&gt;AutoSize = true;
          this-&gt;label4-&gt;Location = System::Drawing::Point(549, 32);
          this-&gt;label4-&gt;Name = L"label4";
          this-&gt;label4-&gt;Size = System::Drawing::Size(103, 13);
          this-&gt;label4-&gt;TabIndex = 9;
          this-&gt;label4-&gt;Text = L"Speed of Movement";
          // 
          // updownX
          // 
          this-&gt;updownX-&gt;Location = System::Drawing::Point(203, 53);
          this-&gt;updownX-&gt;Name = L"updownX";
          this-&gt;updownX-&gt;Size = System::Drawing::Size(85, 20);
          this-&gt;updownX-&gt;TabIndex = 12;
          // 
          // updownY
          // 
          this-&gt;updownY-&gt;Location = System::Drawing::Point(309, 52);
          this-&gt;updownY-&gt;Name = L"updownY";
          this-&gt;updownY-&gt;Size = System::Drawing::Size(80, 20);
          this-&gt;updownY-&gt;TabIndex = 13;
          // 
          // tmrspeed
          // 
          this-&gt;tmrspeed-&gt;Tick += gcnew System::EventHandler(this, 
     &amp;Form1::tmrspeed_Tick);
          // 
          // Form1
          // 
          this-&gt;AutoScaleDimensions = System::Drawing::SizeF(6, 13);
          this-&gt;AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
          this-&gt;ClientSize = System::Drawing::Size(740, 493);
          this-&gt;Controls-&gt;Add(this-&gt;updownY);
          this-&gt;Controls-&gt;Add(this-&gt;updownX);
          this-&gt;Controls-&gt;Add(this-&gt;label4);
          this-&gt;Controls-&gt;Add(this-&gt;label3);
          this-&gt;Controls-&gt;Add(this-&gt;label2);
          this-&gt;Controls-&gt;Add(this-&gt;label1);
          this-&gt;Controls-&gt;Add(this-&gt;trackBar1);
          this-&gt;Controls-&gt;Add(this-&gt;btnBotSpawn);
          this-&gt;Controls-&gt;Add(this-&gt;cmbSelect);
          this-&gt;Controls-&gt;Add(this-&gt;pnlGameZone);
          this-&gt;Name = L"Form1";
          this-&gt;Text = L"Form1";
          this-&gt;Load += gcnew System::EventHandler(this, &amp;Form1::Form1_Load);
          (cli::safe_cast&lt;System::ComponentModel::ISupportInitialize^  &gt;
                         (this-&gt;trackBar1))-&gt;EndInit();
          (cli::safe_cast&lt;System::ComponentModel::ISupportInitialize^  &gt;
                       (this-&gt;updownX))-&gt;EndInit();
          (cli::safe_cast&lt;System::ComponentModel::ISupportInitialize^  &gt;e) e) 
                       (this-&gt;updownY))-&gt;EndInit();
          this-&gt;ResumeLayout(false);
          this-&gt;PerformLayout();
  
      }
  
  #pragma endregion
  private: System::Void btnBotSpawn_Click(System::Object^  sender, System::EventArgs^                      
  e)       {
               if ( cmbSelect-&gt;SelectedIndex == 0)
               {
                   x = Decimal::ToInt32(updownX-&gt;Value);
                   y = Decimal::ToInt32(updownY-&gt;Value);
                   CNNBot newBot(x,y,pnlGameZone);
                   CNNBot * temp = &amp;newBot;
                   VList().Add(temp);
               }
           }
  private: System::Void Form1_Load(System::Object^  sender, System::EventArgs^  e) 
       {
  
       }
  
  
  
  private: System::Void tmrspeed_Tick(System::Object^  sender, System::EventArgs^  e) 
       {
           VList().moveAll();
           VList().checkCollisions();
           VList().destroy();
       }
  };
  };
  </code></pre>
  
  <p>This is the error message i get.
  Error   1   error LNK2020: unresolved token (06000003) Prog3.Form1::VList   C:\Users\Duerst\Documents\Visual Studio 2010\Projects\Prog 3\Prog 3\Prog 3.obj  Prog 3</p>
  
  <p>I am a novice programmer so it is probably something pretty basic, but it would be great if you guys could find what I've done wrong.</p>