class design question (inner classes)

coxalan coxalan at web.de
Tue Sep 11 09:15:25 PDT 2007


Roberto Mariottini Wrote:

> coxalan wrote:
> [...]
> > This is definitely more elegant than the first example. But here, every object of 
> type "s.Permutation" stores a reference to the object "s", which I want 
> to avoid.
> 
> You can simply declare the inner class as static. This way it won't 
> store a reference to its container class.
> 
> Ciao

A static outer class will not work, because within the inner class I need access to the class members of the outer class.

But since the outer class will stay constant, there is no need to store this reference again and again for each inner object.



More information about the Digitalmars-d mailing list