12345678910111213141516171819202122232425
struct Point { private: Point(float x, float y) : x{ x }, y{ y }{} struct PointFactory { PointFactory() {}; static Point NewCartesian(float x, float y) { return { x,y }; } static Point NewPolar(float r, float theta) { return { r*cos(theta), r*sin(theta) }; } }; public: float x, y; static PointFactory Factory; }; Point::PointFactory Point::Factory{};