title: Multiple definition of class method
body: <p>I have the file long_arithm.cpp:</p>
  
  <pre><code>#ifndef LONG_ARITHM.CPP
  #define LONG_ARITHM.CPP
  
  #include &lt;iostream&gt;
  #include &lt;list&gt;
  
  namespace long_arithm {
  
      typedef signed char schar;
      enum { error_char = 127 };
  
      class longint {
      public:
          longint() : minusSign(0), array() { }
          longint(int num) { fromInt(num); }
          longint(std::string str) { fromString(str); }
          longint(const longint&amp; other) : minusSign(other.minusSign), array(other.array) { }
  
          void fromInt(int num);
          void fromString(std::string str);
  
      protected:
          schar digtochar(schar num);
          schar chartodig(schar ch);
  
          inline bool isDigit(schar ch) { /* code */ }
          inline bool isSpaceChar(schar ch) { /* code */ }
  
      private:
          bool minusSign;
          std::list&lt;schar&gt; array;
      };
  };
  
  
  void long_arithm::longint::fromInt(int num) {
      /* code */
  }
  
  void long_arithm::longint::fromString(std::string str) {
      /* code */
  
  long_arithm::schar long_arithm::longint::digtochar(schar num) {
      /* code */
  }
  
  long_arithm::schar long_arithm::longint::chartodig(schar ch) {
      /* code */
  }
  
  #endif
  </code></pre>
  
  <p>Now I'm trying build it, but I have errors (1st and 2nd lines - Eclipce header):</p>
  
  <pre><code>Building target: long_arithmetics
  Invoking: Cross G++ Linker
  g++  -o "long_arithmetics"  ./long_arithm.o ./main.o   
  ./main.o: In function `long_arithm::longint::fromInt(int)':
  /home/gxoptg/Документы/My works/Developing/C++/long_arithmetics/Debug/../long_arithm.cpp:153: multiple definition of `long_arithm::longint::fromInt(int)'
  ./long_arithm.o:/home/gxoptg/Документы/My works/Developing/C++/long_arithmetics/Debug/../long_arithm.cpp:153: first defined here
  ./main.o: In function `long_arithm::longint::fromString(std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;)':
  /home/gxoptg/Документы/My works/Developing/C++/long_arithmetics/Debug/../long_arithm.cpp:168: multiple definition of `long_arithm::longint::fromString(std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;)'
  ./long_arithm.o:/home/gxoptg/Документы/My works/Developing/C++/long_arithmetics/Debug/../long_arithm.cpp:168: first defined here
  ./main.o: In function `long_arithm::longint::chartodig(signed char)':
  /home/gxoptg/Документы/My works/Developing/C++/long_arithmetics/Debug/../long_arithm.cpp:204: multiple definition of `long_arithm::longint::chartodig(signed char)'
  ./long_arithm.o:/home/gxoptg/Документы/My works/Developing/C++/long_arithmetics/Debug/../long_arithm.cpp:204: first defined here
  ./main.o: In function `long_arithm::longint::digtochar(signed char)':
  /home/gxoptg/Документы/My works/Developing/C++/long_arithmetics/Debug/../long_arithm.cpp:188: multiple definition of `long_arithm::longint::digtochar(signed char)'
  ./long_arithm.o:/home/gxoptg/Документы/My works/Developing/C++/long_arithmetics/Debug/../long_arithm.cpp:188: first defined here
  </code></pre>
  
  <p>(Note, the line links (like :188) are broken, because I threw out a lot of commented lines of code.)</p>
  
  <p>Why I have that errors and what I should correct? As good as I understand,</p>
  
  <pre><code>void fromInt(int num);
  </code></pre>
  
  <p>and others are 'pre-definitions', and I don't see any other definitions of that methods.</p>
  
  <p>Thank you for help.</p>