Assuming the original post was just a "simplified" case of a more complex program,
you have to instantiate Nestedclass somewhere. As you've written it, all you've done is declared
Nestedclass to be a type whose scope is limited to Outerclass.
What you intend to do with Nestedclass is unclear. For example, is Outerclass supposed to contain an
instance of Nestedclass? Or is the user supposed to instantiate Nestedclass also?
Your proposed solution implies that the user is supposed to instantiate both, in which case the syntax
would be
I want outerClass(object) to contain an instance of Nestedclass, so I access x by doing this: outerClass.nestedClass.x=5
Is Zhuge's answer the only way to do this?
Because I want to define the Nestedclass(class) inside of the Outerclass definition.
I have the same doubt.....By making a single instance of outer class how can i use the innner class.....OR how can i make the object of inner class when i have the object of outer class....