473,804 Members | 3,225 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

What does extending a class mean?

Hi, I read this in a book about the Xml classes in c#:

"These classes are abstract and therefore must be extended."

I just wanted to know what this statement means. I know it is not in
context, but the author gave it in such a matter that it appears
experience folks will know what it means to say a class is abstract and
extended.

Thanks.

Nov 17 '05 #1
5 2943
Basically, it means that you have to derive from the abstract base class
and implement functionality exposed by it (through abstract methods).

So if you had this:

public abstract class AbstractBase
{
// This needs to be implemented in any derived classes.
public abstract void DoSomething();
}

You need to do this:

public class Derived : AbstractBase
{
public override void DoSomething()
{
// Provide some implementation here.
}
}

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

<ne***********@ gmail.com> wrote in message
news:11******** *************@f 14g2000cwb.goog legroups.com...
Hi, I read this in a book about the Xml classes in c#:

"These classes are abstract and therefore must be extended."

I just wanted to know what this statement means. I know it is not in
context, but the author gave it in such a matter that it appears
experience folks will know what it means to say a class is abstract and
extended.

Thanks.

Nov 17 '05 #2
ne***********@g mail.com wrote:
Hi, I read this in a book about the Xml classes in c#:

"These classes are abstract and therefore must be extended."

I just wanted to know what this statement means. I know it is not in
context, but the author gave it in such a matter that it appears
experience folks will know what it means to say a class is abstract
and extended.

Thanks.


An abstract baseclass might contain some code (methods), but at least
has one "abstract" method. This is not a "real" method at all (it contains no
code), but rather some sort of "placeholde r". By using an abstract method
you declare that all derived classes (classes that use this abstract class
as a baseclass) also have this method. If those derived classes are not
abstract themselves, they *must* provide code ("implement" ) these
abstract methods.

Why have methods that you can't use?
You can use that abstract type as a parameter type for some method
(this method might be in the same baseclass, or somewhere else).
When you call that method you have to specify some "real" object, that
derives from the (abstract) baseclass. Because the method (-signature)
is defined in that baseclass, the method (or rather compiler) knows it can
use it. How it is implemented is not important.

Hans Kesting
Nov 17 '05 #3
An abstract class is one that you can not create instances of. You need to
create a class that inherits from it (extends it) and then you create
instances of this derived class. Abstract classes are used when you want to
provide base functionality that you need to refine necessarily in derived
class. For example, you can have an abstract class Animal (you can not
create instances of it, since it is so generic or "abstract" ...) and you
derive classes extending it like Dog, Cat, etc, which are creatable classes.

--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
You can code, design and document much faster.
Free resources for add-in developers:
http://www.mztools.com

<ne***********@ gmail.com> escribi en el mensaje
news:11******** *************@f 14g2000cwb.goog legroups.com...
Hi, I read this in a book about the Xml classes in c#:

"These classes are abstract and therefore must be extended."

I just wanted to know what this statement means. I know it is not in
context, but the author gave it in such a matter that it appears
experience folks will know what it means to say a class is abstract and
extended.

Thanks.

Nov 17 '05 #4
abstract classes are similar to Interfaces in that you can designate
signatures of methods, but different from interfaces in that you can
specifically implement functionality within an abstract class whereas
in an interface you are constrained to only having signatures of its
members.

interface ISomething
{
void DoSomething();
void DoSomethingElse ();
}

abstract class Something
{
void DoSomething();
void DoSomethingElse ()
{
// code here
}
}

Nov 17 '05 #5
I also forgot to actually answer your original question. But it appears
it has mostly been taken care of by others. Basically an abstract class
cannot be used by itself and must be inherited from by another class.

If a member of an abstract class is abstract itself:

abstract class Something
{
public abstract void DoSomething();
public void DoSomethingElse ()
{
// code here
}
}

The inheriting class must override the abstract member of the abstract
class, but is not required to implement the non-abstract members.

public class MySomething : Something
{
public override void DoSomething()
{
// code here
}
}

Nov 17 '05 #6

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

Similar topics

220
19192
by: Brandon J. Van Every | last post by:
What's better about Ruby than Python? I'm sure there's something. What is it? This is not a troll. I'm language shopping and I want people's answers. I don't know beans about Ruby or have any preconceived ideas about it. I have noticed, however, that every programmer I talk to who's aware of Python is also talking about Ruby. So it seems that Ruby has the potential to compete with and displace Python. I'm curious on what basis it...
9
1845
by: Sasha | last post by:
Hi, I am extending standard IEnumerator, and I was just wondering what is the best way to make enumarator safe? What do I mean by safe? Detect deletes and all... My idea is to have private Guid state field in the collection, and every time something is inserted or deleted from the collection, I will just change the guid. Enumerator will just have to compare the guid received in the begging to the current one. If they are different, the...
3
2080
by: Sathyaish | last post by:
I wanted to practice some Linked List stuff, so I set out to create a linked list. The plan was to create the following: (1) A linked list class in Visual Basic (2) A non-class based linked list using functions in C (3) A linked list class in C++ I started with Visual Basic and I wrote an IList interface that I wanted my list to implement. When I had started, somehow I thought this time, I'd first use a collection as the ingredient,...
7
1646
by: A Traveler | last post by:
Hello all, i was just curious if anyone whos been playing with VS2005 could tell me... In javascript (and java??) you can alter the prototypes for an object in your project. I dont remember the syntax exactly, but basically you do something like: function String.prototype.mySplit(myArgs){...do something...}
9
2370
by: DrBonzo | last post by:
Is there any effective difference between doing something in the DragDrop event handler and doing it in the OnDragDrop(.) method of a control? I'm coming from a MFC background and am having a hard time comprehending the difference. Thanks for your explanations . . .
669
26268
by: Xah Lee | last post by:
in March, i posted a essay “What is Expressiveness in a Computer Language”, archived at: http://xahlee.org/perl-python/what_is_expresiveness.html I was informed then that there is a academic paper written on this subject. On the Expressive Power of Programming Languages, by Matthias Felleisen, 1990. http://www.ccs.neu.edu/home/cobbe/pl-seminar-jr/notes/2003-sep-26/expressive-slides.pdf
16
4087
by: chosechu | last post by:
Hello Pythoneers: I need to pass a list of named arguments to a function in a given order, and make sure these named arguments are retrieved using keys() in the same order they were given. Example: keyargs={} keyargs=1 keyargs=2
13
3507
by: Ben Voigt | last post by:
Is there any way to have an overridden method which is not callable from the assembly overridding it? A contrived example (though I want this feature, my program has nothing to do with food service): Specifically, how can the DemonstrateConditions method be implemented by GoodEats, so that it can be called by HealthBureau and not by GoodEatsWaiter? Assembly A {
8
2379
by: Floortje | last post by:
Hi i have been struggeling with this question for quite some time now. I have some helper classes that handle images (upload an image, create thumbnails and show a imagelist), links (add link, edit link, show linklist), comments (add comment, show commentlist) etc. I do not need all this functionality on every page. Ideally I could just extend the controller like this
0
9588
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10340
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10327
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7625
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6857
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5527
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5663
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3828
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2999
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.