To Hide inherited members

  • Thread starter Thread starter Tommaso Caldarola
  • Start date Start date
T

Tommaso Caldarola

public abstract class A
{
public virtual MethodOne()
{
}

public void AbstractMethod();

}

public abstract class B : A
{
// How to hide MethodOne and AbstractMethod?
}


Inviato da X-Privat.Org - Registrazione gratuita http://www.x-privat.org/join.php
 
Tommaso said:
public abstract class A
{
public virtual MethodOne()
{
}

public void AbstractMethod();

}

public abstract class B : A
{
// How to hide MethodOne and AbstractMethod?
}

You can hide them in terms of creating a new method which will be
called if the type is known to be B at compile time, but where A's
version will be called if the type is only known to be A at
compile-time. However, you can't hide them in terms of preventing
people from calling them. Doing so would violate Liskov's Substitution
Principle - you should always be able to treat a derived type as the
base type.

Jon
 
public abstract class A
{
public virtual MethodOne()
{
}

public void AbstractMethod();

}

public abstract class B : A
{
// How to hide MethodOne and AbstractMethod?
}

public abstract class B //: A
{
// How to hide MethodOne and AbstractMethod?
}
 
"Tom Porterfield" <[email protected]> a écrit dans le message de (e-mail address removed)...

| public abstract class B //: A
| {
| // How to hide MethodOne and AbstractMethod?
| }

Heheh !! Short, sweet and to the point :-)

To explain to the OP, if you need to hide anything from a superclass, you've
got the design wrong.

Joanna
 
Back
Top