title: I need help separating class code in C++ LNK2005 and LNK1169
body: <p>I'm new at C++ and I have to create a simple video game, that has an enemy class, the problem comes when I try to separate the enemy code from the main.cpp, creating enemy.h and enemy.cpp, I followed all instructions I saw on the internet but it keeps showing me the error message I hope you guys can help me.</p>
  
  <p><strong>enemy.cpp file</strong></p>
  
  <pre><code>#include "enemy.h"
  
  enemy::enemy(int _hp, int _attackValue, string _name) {
      hp = _hp;
      attackValue = _attackValue;
      name = _name;
  }
  
  void enemy::attack(enemy agressor, enemy objective) {
      objective.set_hp(objective.hp - agressor.attackValue);
      objective.showinfo(objective, 2);
  }
  
  void enemy::showinfo(enemy enemy, int hero) {
      if (hero == 1) {
          cout &lt;&lt; "     \n\n\n\n\n\n\n";
          cout &lt;&lt; enemy.name;
          cout &lt;&lt; "     \n\n\n\n\n\n\n\n";
          for (int i = enemy.hp / 5; i &gt; 0; i--) {
              cout &lt;&lt; "|";
          }
          cout &lt;&lt; "     \n\n\n\n\n\n\n\n\n";
          cout &lt;&lt; enemy.hp;
      }
      else {
          cout &lt;&lt; "                                   \n\n\n\n\n\n\n";
          cout &lt;&lt; enemy.name;
          cout &lt;&lt; "                                   \n\n\n\n\n\n\n\n";
          for (int i = enemy.hp / 5; i &gt; 0; i--) {
              cout &lt;&lt; "|";
          }
          cout &lt;&lt; "                                   \n\n\n\n\n\n\n\n\n";
          cout &lt;&lt; enemy.hp;
      }
  }
  
  int enemy::get_hp() {
      return hp;
  }
  
  void enemy::set_hp(int _hp) {
      hp = _hp;
  }
  
  int enemy::get_attackValue() {
      return attackValue;
  }
  
  string enemy::get_name() {
      return name;
  }
  </code></pre>
  
  <p><strong>enemy.h file</strong></p>
  
  <pre><code>#pragma once
  
  #ifndef enemy_H
  #define enemy_H
  
  class enemy {
  
  private:
  
      int hp, attackValue;
      string name;
  public:
      enemy();
      enemy(int, int, string);
      void attack(enemy, enemy);
      void showinfo(enemy, int);
      int get_hp();
      void set_hp(int hp);
      int get_attackValue();
      string get_name();
  };
  
  #endif // !enemy_H
  </code></pre>
  
  <p>PD: I still don't know how to implement setcursorposition in c++ as you can see.</p>