nested private struct visible from outside??

Hi,

I have a nested struct in the private sector of another struct yet is visible from the outside... why?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
	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{};


Can use static member Factory even though Point::PointFactory is hidden inside Point!

could it be types including aliases don't care about visibility constraints?

Regards,
Juan
No, I am sorry ... Factory is a static instance of PointFactory defined inside Point - thus use of PointFactory is done inside the sorrounding struct and is not exposed to the outside!!


Sorry...
Last edited on
Topic archived. No new replies allowed.