"Private" nested classes
From: Etienne Boucher (etienne_at_novat.qc.ca)
Date: 07/29/04
- Next message: Vivek: "Re: Crystal report"
- Previous message: Sorin Sandu: "Re: Search for strings"
- Next in thread: Richard A. Lowe: "Re: "Private" nested classes"
- Reply: Richard A. Lowe: "Re: "Private" nested classes"
- Reply: Hans Kesting: "Re: "Private" nested classes"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 29 Jul 2004 00:29:28 -0400
Nested classes are usualy objects made to only live in their parent object
instance. In other words...
public class Outter
{
public class Inner
{
}
}
Prevent being able to use "new Outter.Inner()", in Main for exemple, while
still being able to access the members of Inner.
This could be done with a public interface implemented in a private nested
class, or like this:
public class Outter
{
private Inner i;
public Outter()
{
new Inner(this);
}
public class Inner
{
private Outter o;
public Inner(Outter o)
{
if (null != o.i)
throw new Exception();
o.i = this;
this.o = o;
}
}
}
But that's not very clean. Any one can think of a better way?
Etienne Boucher
- Next message: Vivek: "Re: Crystal report"
- Previous message: Sorin Sandu: "Re: Search for strings"
- Next in thread: Richard A. Lowe: "Re: "Private" nested classes"
- Reply: Richard A. Lowe: "Re: "Private" nested classes"
- Reply: Hans Kesting: "Re: "Private" nested classes"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|