473,386 Members | 1,817 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

To Hide inherited members

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
Apr 19 '06 #1
5 8598
Tommaso Caldarola wrote:
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

Apr 19 '06 #2
On Wed, 19 Apr 2006 12:00:40 +0200, Tommaso Caldarola wrote:
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
Apr 19 '06 #3
"Tom Porterfield" <tp******@mvps.org> a écrit dans le message de news:
1p***************@tpportermvps.org...

| 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

--
Joanna Carter [TeamB]
Consultant Software Engineer
Apr 19 '06 #4
Hi,

"Tom Porterfield" <tp******@mvps.org> wrote in message
news:1p***************@tpportermvps.org...

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


Subtle :)

R u english by any chance?
Apr 19 '06 #5
Ignacio Machin ( .NET/ C# MVP ) wrote:
Hi,

"Tom Porterfield" <tp******@mvps.org> wrote in message
news:1p***************@tpportermvps.org...

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


Subtle :)

R u english by any chance?


Nope, American, but I studied English in college.
--
Tom Porterfield
Apr 19 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: C-Sharper or C-Hasher, one of the two | last post by:
Hi, I have a C# class libary (Class1) which is inherited by another class in a Windows Forms app. I want this other class to implement some, but not all of the features of the base class. How...
6
by: Alex Sedow | last post by:
Example 1 interface I { string ToString(); } public class C : I { public void f() {
1
by: skootr | last post by:
I have a Public Interface defined in a class module. I also have a form that implements that interface After building the solution, I added an Inherited Form (inherited from the above-mentioned...
6
by: Peter Oliphant | last post by:
I just discovered that the ImageList class can't be inherited. Why? What could go wrong? I can invision a case where someone would like to add, say, an ID field to an ImageList, possible so that...
2
by: lovecreatesbeauty | last post by:
I'm disturbed on this question on a long time. I think if I finally get understand it with your kind help, I will get close to a excellent C++ programmer. And I only can rely on your expertise and...
2
by: Giojo | last post by:
Hello guys! I have a problem with vistual studio 2005, it's a strange problem... I have a form, I choose some properties to change so in *.designer.cs there are the members I changed, only these.....
14
by: lovecreatesbea... | last post by:
Could you tell me how many class members the C++ language synthesizes for a class type? Which members in a class aren't derived from parent classes? I have read the book The C++ Programming...
19
by: jan.loucka | last post by:
Hi, We're building a mapping application and inside we're using open source dll called MapServer. This dll uses object model that has quite a few classes. In our app we however need to little bit...
2
by: eggie5 | last post by:
Hi, I have a class Dog which derives from Animal. Suppose my instance of Dog is bulldog. bulldog has all the members of Animal plus Dog. How can copy just the members from Dog to a new Dog...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.