抽象クラスと、保護されたコンストラクターのみを持つクラスのすべての違いは何ですか?どちらもインスタンス化できないという点で、私とよく似ているようです。
編集:
保護されたコンストラクターを持つ基本クラスを使用して、派生クラスにインスタンスをどのように作成しますか?例えば:
public class ProtectedConstructor
{
protected ProtectedConstructor()
{
}
public static ProtectedConstructor GetInstance()
{
return new ProtectedConstructor(); // this is fine
}
}
public class DerivedClass : ProtectedConstructor
{
public void createInstance()
{
ProtectedConstructor p = new ProtectedConstructor(); // doesn't compile
}
public static ProtectedConstructor getInstance()
{
return new ProtectedConstructor(); // doesn't compile
}
}