473,323 Members | 1,537 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,323 software developers and data experts.

Interface implementation question.

I checked definition of class CollectionBase

public abstract class CollectionBase : IList, ICollection,
IEnumerable, it implements 3 interface IList, ICollection and
IEnumerable.

I found IList is derived or extended from ICollection and
IEnumerable. Why the definition of class CollectionBase just implement
IList interface which has functions of ICollection and IEnumerable?

Thanks ahead.

Laurence

May 25 '07 #1
1 1699
On Fri, 25 May 2007 08:59:04 -0700, Larry <ch************@gmail.comwrote:
I checked definition of class CollectionBase

public abstract class CollectionBase : IList, ICollection,
IEnumerable, it implements 3 interface IList, ICollection and
IEnumerable.

I found IList is derived or extended from ICollection and
IEnumerable. Why the definition of class CollectionBase just implement
IList interface which has functions of ICollection and IEnumerable?
I'm not exactly clear on what your question is. That is, are you asking:

1) Why does the class CollectionBase *only* implement the IList
interface?

Or are you asking:

2) Why does the class CollectionBase inherit from all three interfaces
even though IList already inherits from ICollection and IEnumerable?

If #1, then the answer is simply that because of the inheritance, there's
no need to implement new methods for the other two interfaces.

If #2, then I don't actually know. I presume it's simply to make the
interfaces more explicit, so that the CollectionBase-derived classes are
guaranteed to still implement the other two base interfaces even if for
some reason IList is changed or removed. But frankly, it seems to me that
doing something like changing IList so that it no longer inherits from the
other two, or removing it from the CollectionBase class altogether would
be an egregious violation of the whole idea of publishing the interfaces
in the first place. Furthermore, if someone *did* make that sort of
change, it would be major enough that they could easily just add in the
two base interfaces after the fact; any caller who only cared about the
base interfaces would still work, and any caller trying to get the base
interfaces from the derived interface would have to be revisited anyway.

Of course, I could be missing something. Happens all the time. :) But I
don't see what the point of inheriting from both the derived interface,
and two base interfaces that derived interface inherits.

Pete
May 25 '07 #2

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

Similar topics

6
by: Paul Fame | last post by:
Hello World, This is not a flame, but a question about the fundamentals of the language. Unlike some languages, C++ requires class member functions to be declared twice: once in the class...
9
by: Anon Email | last post by:
Hi people, I'm learning about header files in C++. The following is code from Bartosz Milewski: // Code const int maxStack = 16; class IStack
175
by: Ken Brady | last post by:
I'm on a team building some class libraries to be used by many other projects. Some members of our team insist that "All public methods should be virtual" just in case "anything needs to be...
20
by: Ole Hanson | last post by:
I am accessing my database through an interface, to allow future substitution of the physical datastore - hence I would like to declare in my Interface that my DAL-objects implementing the...
13
by: John Salerno | last post by:
Hi all. I have a question about interfaces now. According to the book I'm reading, when you implement an interface, the class or structure has to declare all the methods that the interface...
4
by: Ray Dukes | last post by:
What I am looking to do is map the implementation of interface properties and functions to an inherited method of the base class. Please see below. ...
8
by: Gregory | last post by:
I have a question about using STL containers in C++ class public interface. Lets say that I want to return some container from class method or accept class method parameter as some container. For...
2
by: psandler70 | last post by:
All, This might be a stupid question. When defining an interface, is it possible to force the class that implements it to support a property/method with the same name, but not force a...
52
by: Ben Voigt [C++ MVP] | last post by:
I get C:\Programming\LTM\devtools\UselessJunkForDissassembly\Class1.cs(360,27): error CS0535: 'UselessJunkForDissassembly.InvocableInternals' does not implement interface member...
1
by: =?Utf-8?B?Sk0=?= | last post by:
In an application I have an interface with methods and properties. The interface is used on a Class (ie class MyClass : IMyClassA, IMyClassB). On a windows form I define a BindingSource...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.