title: error LNK: unresolved external symbol, resulting from virtual functions
body: <p>Following are the errors when I compile my code. I am sorry that I cannot share my code here. FYI, I don't use any externals libs, so I am really not sure about these linker errors. They seem to come from the virtual functions I declared in <code>DeviceManager</code> class. Their respective implementations are in two other classes.</p>
  
  <p>Could someone help me out with these errors?</p>
  
  <pre><code>1&gt;device_manager.obj : error LNK2028: unresolved token (0A000397) "public: virtual void __clrcall DeviceManager::loadConfig(class System::IO::StreamReader ^)" (?DeviceManager@DeviceManager@@$$FUAMXP$AAVStreamReader@IO@System@@@Z) referenced in function "void __clrcall `dynamic initializer for 'const DeviceManager::`vftable'''(void)" (???__E??_7DeviceManager@@6B@@@YMXXZ@?A0xc2524ebc@@$$FYMXXZ)
  1&gt;device_manager.obj : error LNK2019: unresolved external symbol "public: virtual void __clrcall DeviceManager::loadConfig(class System::IO::StreamReader ^)" (?loadConfig@DeviceManager@@$$FUAMXP$AAVStreamReader@IO@System@@@Z) referenced in function "void __clrcall `dynamic initializer for 'const DeviceManager::`vftable'''(void)" (???__E??_7DeviceManager@@6B@@@YMXXZ@?A0xc2524ebc@@$$FYMXXZ)
  1&gt;device_manager.obj : error LNK2001: unresolved external symbol "public: virtual class Device * __thiscall DeviceManager::createDevice(void)" (?createDevice@DeviceManager@@UAEPAVDevice@@XZ)
  1&gt;device_manager.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall DeviceManager::initializeDevices(void)" (?initializeDevices@DeviceManager@@UAEXXZ)
  1&gt;C:\Users\CH\Documents\Visual Studio 2010\Projects\Test Devices\Test Devices\Debug\Test Devices.exe : fatal error LNK1120: 4 unresolved externals
  1&gt;
  1&gt;Build FAILED.
  1&gt;
  1&gt;Time Elapsed 00:00:01.50
  ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
  </code></pre>
  
  <blockquote>
    <p>Update 1 (Possible Solution):</p>
  </blockquote>
  
  <p>The problem seems to be because of the virtual function(s) declared in <code>DeviceManager</code>class  not being pure virtual and not having definition(s) in the <code>.cpp</code> of <code>DeviceManager</code> class. </p>
  
  <p>If the <code>DeviceManager</code>class does not have any non-virtual function(s), then making the virtual function(s) pure will be the solution. Something like this <code>virtual void testFunction();</code> is not pure, so changing it to <code>virtual void testFunction()=0;</code> is the solution. For this, it is enough to have the definition(s) of this virtual function implemented in other classe(s) that inherit the <code>DeviceManager</code> class. In such a case, the <code>DeviceManager</code>class becomes abstract and therefore cannot be instantiated.</p>
  
  <p>But in my case, the <code>DeviceManager</code>class has some non-virtual functions as well and also needs to be instantiated to call the non-virtual functions. Therefore, the solution is to implement the definitions of the virtual functions in the <code>.cpp</code> of the <code>DeviceManager</code>class apart from declarations and definitions in other classes that inherit the <code>DeviceManager</code> class.</p>