title: Undefined reference to class when the class is defined
body: <p>Recently, I've started learning C++. Knowing some python already, I decided to try and understand pointers, but I've run into an error while trying to compile the file. The error message is a bit confusing, and I've been stuck on it for some time. Answers on SO do offer some insight on the problem, but as I am still new to C++ I don't really understand how to fix it. I've read that it might be a problem with the default constructor declaration, but I'm not really sure what to fix.</p>
  
  <pre><code>#include &lt;cstddef&gt;
  #include &lt;iostream&gt;
  
  using namespace std;
  
  class Uinter
      /*
       * Regrouping class for intervals (_Inter class) 
       * offering 3 different methods:
       *  "reunion(int bi, int bs)" -&gt; Unites the interval pointed by "_tete"
       *                               with the one defined by [bi, bs]
       *  "printUinter()"           -&gt; Prints the interval pointed by "_tete"
       *  "contient(int nb)"        -&gt; Returns True if "nb" is present inside
       *                               the intervals, else False. 
       */
      {
          class _Inter
          /*
           * Class representing a single interval.
           * _bi stands for the lower limit of the interval.
           * _bs stands for the upper limit of the interval.
           */
          {
              int _bi, _bs;
              _Inter* _next;
          public:
              _Inter(int, int, _Inter*);
              // Defining getters and setters for the interval.
              void set_bi(int value)
                  {_bi = value;}
              void set_bs(int value)
                  {_bs = value;}
              void set_next(_Inter* value)
                  {_next = value;}
              int get_bi()
                  {return _bi;}
              int get_bs()
                  {return _bs;}
              _Inter* get_next()
                  {return _next;}
          };
          _Inter* _tete;
      public:
          Uinter(): _tete(nullptr){}
          void reunion(int bi, int bs)
              {
              if(_tete == nullptr)
                  {
                  _Inter new_interval = _Inter(bi, bs, nullptr);
                  _tete = &amp;new_interval;
                  }
              else
                  {
                  if(bi &lt; _tete-&gt;get_bi())
                      {
                      if (bs &lt; _tete-&gt;get_bi())
                          {
                          _Inter new_interval = _Inter(bi, bs, _tete);
                          _tete = &amp;new_interval;
                          }
  
                      else if (bs &gt; _tete-&gt;get_bs())
                          {
                          _Inter new_interval = _Inter(bi, bs, _tete-&gt;get_next());
                          _tete = &amp;new_interval;
                          }
  
                      else if (bs &gt; _tete-&gt;get_bi())
                          {
                          _Inter new_interval = _Inter(bi, _tete-&gt;get_bs(), _tete-&gt;get_next());
                          _tete = &amp;new_interval;
                          }                   
                      }
                  else if (bi &gt; _tete-&gt;get_bi())
                      {
                      if (bi &gt; _tete-&gt;get_bs())
                          {
                          _Inter temp = *_tete-&gt;get_next(); // delete later
                          while(&amp;temp != nullptr &amp;&amp; bi &gt; temp.get_bs())
                              {
                              temp = *temp.get_next();
                              }
                          if (&amp;temp == nullptr)
                              {
                              _Inter new_interval = _Inter(bi, bs, nullptr);
                              //temp.set_next(new_interval);
                              }
                          else if (bi &lt; temp.get_bi())   // bi &lt; temp.get_bs()
                              {
                              if (bs &lt; temp.get_bi())
                                  {
                                  _Inter new_interval = _Inter(bi, bs, _tete);
                                  _tete = &amp;new_interval;
                                  }
  
                              else if (bs &gt; temp.get_bs())
                                  {
                                  _Inter new_interval = _Inter(bi, bs, _tete-&gt;get_next());
                                  _tete = &amp;new_interval;
                                  }
  
                              else if (bs &gt; temp.get_bi())
                                  {
                                  _Inter new_interval = _Inter(bi, _tete-&gt;get_bs(), _tete-&gt;get_next());
                                  _tete = &amp;new_interval;
                                  }                   
                              }
                          else if (bi &gt; temp.get_bi())  // bi &lt; temp.get_bs()
                              {
                              if (bs &gt; temp.get_bs())
                                  {
                                  _Inter new_interval = _Inter(temp.get_bi(), bs, nullptr);
                                  temp = new_interval;
                                  }
                              }
                          }
                      }
  
                  }
              }
          void printUinter();
          bool contient(int nb);
          void order();
      };
  
  
  int main() 
  {
      Uinter interval;
      interval.reunion(12, 23);
  
      return 0;
  }
  </code></pre>
  
  <p>And here is the error message - </p>
  
  <pre><code>"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
  make[1]: Entering directory '/cygdrive/c/Users/Iocust/Documents/NetBeansProjects/CppApplication_2'
  "/usr/bin/make"  -f nbproject/Makefile-Debug.mk dist/Debug/Cygwin_4.x-Windows/cppapplication_2.exe
  make[2]: Entering directory '/cygdrive/c/Users/Iocust/Documents/NetBeansProjects/CppApplication_2'
  mkdir -p dist/Debug/Cygwin_4.x-Windows
  g++ -std=c++11    -o dist/Debug/Cygwin_4.x-Windows/cppapplication_2 build/Debug/Cygwin_4.x-Windows/main.o 
  build/Debug/Cygwin_4.x-Windows/main.o: In function `Uinter::reunion(int, int)':
  /cygdrive/c/Users/Iocust/Documents/NetBeansProjects/CppApplication_2/main.cpp:56: undefined reference to `Uinter::_Inter::_Inter(int, int, Uinter::_Inter*)'
  /cygdrive/c/Users/Iocust/Documents/NetBeansProjects/CppApplication_2/main.cpp:56:(.text$_ZN6Uinter7reunionEii[_ZN6Uinter7reunionEii]+0x3f): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `Uinter::_Inter::_Inter(int, int, Uinter::_Inter*)'
  /cygdrive/c/Users/Iocust/Documents/NetBeansProjects/CppApplication_2/main.cpp:65: undefined reference to `Uinter::_Inter::_Inter(int, int, Uinter::_Inter*)'
  /cygdrive/c/Users/Iocust/Documents/NetBeansProjects/CppApplication_2/main.cpp:65:(.text$_ZN6Uinter7reunionEii[_ZN6Uinter7reunionEii]+0xa4): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `Uinter::_Inter::_Inter(int, int, Uinter::_Inter*)'
  /cygdrive/c/Users/Iocust/Documents/NetBeansProjects/CppApplication_2/main.cpp:71: undefined reference to `Uinter::_Inter::_Inter(int, int, Uinter::_Inter*)'
  /cygdrive/c/Users/Iocust/Documents/NetBeansProjects/CppApplication_2/main.cpp:71:(.text$_ZN6Uinter7reunionEii[_ZN6Uinter7reunionEii]+0xf7): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `Uinter::_Inter::_Inter(int, int, Uinter::_Inter*)'
  /cygdrive/c/Users/Iocust/Documents/NetBeansProjects/CppApplication_2/main.cpp:77: undefined reference to `Uinter::_Inter::_Inter(int, int, Uinter::_Inter*)'
  /cygdrive/c/Users/Iocust/Documents/NetBeansProjects/CppApplication_2/main.cpp:77:(.text$_ZN6Uinter7reunionEii[_ZN6Uinter7reunionEii]+0x154): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `Uinter::_Inter::_Inter(int, int, Uinter::_Inter*)'
  /cygdrive/c/Users/Iocust/Documents/NetBeansProjects/CppApplication_2/main.cpp:99: undefined reference to `Uinter::_Inter::_Inter(int, int, Uinter::_Inter*)'
  /cygdrive/c/Users/Iocust/Documents/NetBeansProjects/CppApplication_2/main.cpp:99:(.text$_ZN6Uinter7reunionEii[_ZN6Uinter7reunionEii]+0x23d): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `Uinter::_Inter::_Inter(int, int, Uinter::_Inter*)'
  build/Debug/Cygwin_4.x-Windows/main.o:/cygdrive/c/Users/Iocust/Documents/NetBeansProjects/CppApplication_2/main.cpp:105: more undefined references to `Uinter::_Inter::_Inter(int, int, Uinter::_Inter*)' follow
  build/Debug/Cygwin_4.x-Windows/main.o: In function `Uinter::reunion(int, int)':
  /cygdrive/c/Users/Iocust/Documents/NetBeansProjects/CppApplication_2/main.cpp:105:(.text$_ZN6Uinter7reunionEii[_ZN6Uinter7reunionEii]+0x28d): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `Uinter::_Inter::_Inter(int, int, Uinter::_Inter*)'
  /cygdrive/c/Users/Iocust/Documents/NetBeansProjects/CppApplication_2/main.cpp:111:(.text$_ZN6Uinter7reunionEii[_ZN6Uinter7reunionEii]+0x2e8): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `Uinter::_Inter::_Inter(int, int, Uinter::_Inter*)'
  /cygdrive/c/Users/Iocust/Documents/NetBeansProjects/CppApplication_2/main.cpp:119:(.text$_ZN6Uinter7reunionEii[_ZN6Uinter7reunionEii]+0x349): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `Uinter::_Inter::_Inter(int, int, Uinter::_Inter*)'
  collect2: error: ld returned 1 exit status
  nbproject/Makefile-Debug.mk:62: recipe for target 'dist/Debug/Cygwin_4.x-Windows/cppapplication_2.exe' failed
  make[2]: *** [dist/Debug/Cygwin_4.x-Windows/cppapplication_2.exe] Error 1
  make[2]: Leaving directory '/cygdrive/c/Users/Iocust/Documents/NetBeansProjects/CppApplication_2'
  nbproject/Makefile-Debug.mk:59: recipe for target '.build-conf' failed
  make[1]: *** [.build-conf] Error 2
  make[1]: Leaving directory '/cygdrive/c/Users/Iocust/Documents/NetBeansProjects/CppApplication_2'
  nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed
  make: *** [.build-impl] Error 2
  </code></pre>
  
  <p>I am sorry for providing such an unclear code. If it is of any relevance, I'm using NetBeans 8.0.2.</p>