I've the following class called as Point which also contains an inner class called as PointFactory. The Point class has a static instance of the inner class PointFactory as Factory present inside it.
class Point{
private:
float x, y;
Point(float a, float b){
x = a;
y = b;
}
public:
struct PointFactory{
PointFactory(){}
Point newCartesian(float x, float y){
return {x, y};
}
Point newPolar(float rho, float theta){
return {rho*cos(theta), rho*sin(theta)};
}
};
static PointFactory Factory();
};
I'm trying to access the methods - newCartesian and newPolar from the the static instance Factory as follows:
Point point = Point::Factory.newCartesian(10, 20);
Point point2 = Point::Factory.newPolar(100, 200);
But, I get 2 errors saying that the methods newCartesian and newPolar couldn't be resolved. I understand the static variables need to be initialized and I believe I've done that.
I would like to know the reason for the above mentioned errors.