Any class, not a "sub-class". There are two aspects of this.
First of all, this class can be abstract, which cannot be instantiated by definition.
But there are cases when you want to have instances of the class, but protect the user of the class from direct instantiation of the class through initialization of a variable or a member by constructing an instance of this class. This is done by creating a class without accessible constructors. How? The only tricky thing is to eliminate default constructor. For this purpose, define
private
constructor without parameters. It doesn't need any significant body/implementation, it can be empty. If you do so, any initialization statement of such class will cause compilation error.
The purpose of these techniques is to use this class as a base class for other classes which can be instantiated. In second technique, this is the way to allow creation of the instances of the class only in some special way (using
factory methods), not directly. The variation of this technique would be using different access modifiers, for example, to allow creation of an instance only for derived class, then
protected
access modifier should be used; and so on:
http://msdn.microsoft.com/en-us/library/76453kax.aspx[
^].
—SA