kmrneedsnethelp
2007-06-06 17:46:00 UTC
I have the class structure shown below. When I compile I receive the
following erros:
'B.B()' is inaccessible due to its protection level
'C.C()' is inaccessible due to its protection level
I am sure it is because of the protected keyword on the constructors for B
and C but I do not understand the underlying reason.
Can anyone explain it?
Thanks in advance!
abstract class A
{
public enum AType {BType, CType};
protected A()
{
}
public static A CreateAFactory(AType typ)
{
switch(typ)
{
case AType.BType:
return new B();
case AType.CType:
return new C();
}
}
}
class B : A
{
protected B() : base()
{
}
}
class C : A
{
protected C() : base()
{
}
}
following erros:
'B.B()' is inaccessible due to its protection level
'C.C()' is inaccessible due to its protection level
I am sure it is because of the protected keyword on the constructors for B
and C but I do not understand the underlying reason.
Can anyone explain it?
Thanks in advance!
abstract class A
{
public enum AType {BType, CType};
protected A()
{
}
public static A CreateAFactory(AType typ)
{
switch(typ)
{
case AType.BType:
return new B();
case AType.CType:
return new C();
}
}
}
class B : A
{
protected B() : base()
{
}
}
class C : A
{
protected C() : base()
{
}
}