I have a very strange question here. I have Class A, Class B and Class C. I want to create object of Class B which can create the object of A. But how to restrict Class C from creating object of Class A.
One way is define Class A inside Class B, so that Only Class B can create the instance of Class A and Class C cannot access Class A.
But, I think nesting is a wrong way.
Do we have any way to restrict the object creation? Is it possible to use attribute and reflection to help to restrict? If possible is there a recommended way?
Please share your thoughts. Thanks in advance.