title: Linker error if the members are not static in the following Inner-Factory example, why?
body: <p>I get Linker errors in the following example if I keep the PointFactory member functions as non-static.</p>
  <pre><code>#define _USE_MATH_DEFINES
  #include &lt;cmath&gt;
  #include &lt;iostream&gt;
  
  class Point {
    private:
      Point(const double x, const double y) :
      x(x), y(y) {}
  
      class PointFactory {
        public:
          static Point NewCartesian(double x, double y) {
            return {x, y};
          }
  
          static Point NewPolar(double r, double theta) {
            return {r*cos(theta), r*sin(theta)};
          }
      };
  
    public:
      double x, y;
  
      // Needs to be friend coz stream object requires access to member variables
      friend std::ostream&amp; operator&lt;&lt;(std::ostream&amp; os, Point const&amp; obj) {
        return os &lt;&lt; &quot;x: &quot; &lt;&lt; obj.x &lt;&lt; &quot; y: &quot; &lt;&lt; obj.y;
      }
      
      static PointFactory Factory;
  };
  
  int main() {
    auto pt = Point::Factory.NewPolar(5, M_PI_4);
    std::cout &lt;&lt; pt &lt;&lt; std::endl; 
    getchar();
    return 0;
  }
  </code></pre>
  <p>Why do I need PointFactory members to be static? What is the reasoning behind this?</p>