title: Undefined reference to class::function
body: <p>I've been doing C programming for uni and in my spare time I'm moving onto c++ and am trying to start with classes in seperate files and whatnot, but I'm getting some problems when trying to make my project. I'm using the following makefile</p>
  
  <pre><code>EXEC = main
  OBJS = main.o Bunny.o Name.o Board.o
  CC = g++
  
  CFLAGS = -Wall -Wextra -Werror
  LIBS = 
  LDFLAGS = 
  
  
  $(EXEC): $(OBJS)
      $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
  
  
  
  .PHONY: clean
  
  clean: 
      rm -f $(EXEC) $(OBJS) 
  run:
      ./$(EXEC)
  </code></pre>
  
  <p>Which is just an altered version of my C one so it might be that, and here are the relevant other files</p>
  
  <p>main.cpp</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  #include "Name.hpp"
  #include "definitions.hpp"
  
  int main() {
  
      Name nameContainer;
  
      nameContainer.initMaleNameValidArray(); 
  
      std::cout &lt;&lt; "Got to just before the return!\n" &lt;&lt; std::endl;
  
      return 0;
  }
  </code></pre>
  
  <p>Name.cpp</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;fstream&gt;
  #include &lt;string&gt;
  #include "definitions.hpp"
  
  class Name{
      public:
          void initFemaleNameArray() {
              std::ifstream myReadFile;
              myReadFile.open("girlsnames.txt");
              char output[100];
              if (myReadFile.is_open()) {
                  while (!myReadFile.eof()) {
                      myReadFile &gt;&gt; output;
                      std::cout&lt;&lt;output;
                  }
              }
              myReadFile.close();
          }
  
          void initMaleNameArray() {
  
          }
  
          void initFemaleNameValidArray() {
              static int femaleValidArray[GIRLS_NAMES] = {0};
          }
  
          void initMaleNameValidArray() {
              static int MaleValidArray[GIRLS_NAMES] = {0};
          }
  
          void freeAFemaleName(std::string name);
  
          void freeAMaleName(std::string name);
  
          std::string returnFreeFemaleName();
  
          std::string returnFreeMaleName();
  
      private:
          std::string femaleNameArray[GIRLS_NAMES];
  
          std::string maleNameArray[BOYS_NAMES];
  
          int femaleValidArray[GIRLS_NAMES];
  
          int maleValidArray[BOYS_NAMES];
  };
  </code></pre>
  
  <p>Name.hpp</p>
  
  <pre><code>#ifndef NAME_HPP
  #define NAME_HPP
  
  #include "definitions.hpp"
  
  class Name{
      public:
          void initFemaleNameArray();
  
          void initMaleNameArray();
  
          void initFemaleNameValidArray();
  
          void initMaleNameValidArray();
  
          void freeAFemaleName(std::string name);
  
          void freeAMaleName(std::string name);
  
          std::string returnFreeFemaleName();
  
          std::string returnFreeMaleName();
  
      private:
          std::string femaleNameArray[GIRLS_NAMES];
  
          std::string maleNameArray[BOYS_NAMES];
  
          int femaleValidArray[GIRLS_NAMES];
  
          int maleValidArray[BOYS_NAMES];
  };
  
  #endif
  </code></pre>
  
  <p>And the error im getting when running make is:</p>
  
  <pre><code>mark@Mark-Linux:~/Documents/Misc/C++/Bunny$ make
  g++    -c -o main.o main.cpp
  g++    -c -o Bunny.o Bunny.cpp
  g++    -c -o Name.o Name.cpp
  g++    -c -o Board.o Board.cpp
  g++  -o main main.o Bunny.o Name.o Board.o 
  main.o: In function `main':
  main.cpp:(.text+0x26): undefined reference to `Name::initFemaleNameArray()'
  collect2: ld returned 1 exit status
  make: *** [main] Error 1
  </code></pre>
  
  <p>At the moment I'm just trying to see if I can use a method from a class in a different file hence the incompleteness of the code.</p>
  
  <p>Sorry about the wall of text but I'm well and truly stumped, so if anyone could offer any advice that'd be greatly appreciated.</p>