title: calling a function from a class inside a namespace?
body: <p>I wrote a code with a class existing inside a namespace.</p>
  <p>This is the header file: As you can see, the class is created inside the namespace, in frileg.h.</p>
  <pre><code>namespace frileg
  {
      class legeplads
      {
      public:
          int x;
          int y;
          int z;
          void print();
      };
  }
  </code></pre>
  <p>Then I also have defined the function print() inside the legeplads.cpp:</p>
  <pre><code>void frileg::legeplads::print()
  {
      std::cout &lt;&lt; &quot;pos: {&quot; &lt;&lt; x &lt;&lt; &quot;, &quot; &lt;&lt; y &lt;&lt; &quot;, &quot; &lt;&lt; z &lt;&lt; &quot;}&quot; &lt;&lt; std::endl;
  }
  </code></pre>
  <p>but when I run the code in the main function, I get an error: &quot;undefined reference to `frileg::legeplads::print()':&quot;</p>
  <pre><code>int main(){
  
      legeplads a;
      a.x = 1;
      a.y = 2;
      a.z = 3;
      a.print();
      return 0;
  }
  </code></pre>