abstract class

S

sam_cit

Hi Everyone,

We know that objects of Abstract class can't be created and functions
of abstract class have to be overriden by the child class, so this
makes me think as to what is the use of having a abstract class in
programming?

Thanks in advance
 
O

Ondra Holub

(e-mail address removed) napsal:
Hi Everyone,

We know that objects of Abstract class can't be created and functions
of abstract class have to be overriden by the child class, so this
makes me think as to what is the use of having a abstract class in
programming?

Thanks in advance

Abstract class gives to the user some interface which must be
fulfilled. The requirement to overwrite some functions forces the user
of class to provide required interface.
 
A

andrewmcdonagh

Hi Everyone,

We know that objects of Abstract class can't be created and functions
of abstract class have to be overriden by the child class, so this
makes me think as to what is the use of having a abstract class in
programming?

Thanks in advance

It allows abstraction to take place.

The entire code base can now know only about the Abstract class and use
its virtual methods.
There can then be only one small place where the real concrete classes
that derive from them, need be specifiied and used.

Its certainly very useful for APIs, where you want your 3rd party
library to be useful by others, without them having to know which
specific concrete classes to use. This flexablity creates numerous
benefits....

Andrew
 
J

Jim Langston

Hi Everyone,

We know that objects of Abstract class can't be created and functions
of abstract class have to be overriden by the child class, so this
makes me think as to what is the use of having a abstract class in
programming?

Thanks in advance

I made an abstract class for someone today to show him some things and I
think he'll actually use it wth modificaton in production code.

The abstract class is a base class for a polymophic type that he will have a
vector of. Even though the abstract base class can't be instatized, the
derived classes can. And a base class is required for polymorphism. That's
what I normally use them for anyway.
 
G

Grizlyk

We know that objects of Abstract class can't be created and functions
of abstract class have to be overriden by the child class, so this
makes me think as to what is the use of having a abstract class in
programming?

The classes are using to declare interface. From C language point of
view, class is similar to module, so must have interface, with the help
of which all other parts of program call the module implementation.
Interface can have no code, as Abstract class do.

Unlike to single C module, C++ program can have many modules with the
same interface of the Abstract class, having equal or different
implementation, and able to be changed at runtime without relink.

For example, Abstract class can describe interface of video system, and
concrete implementation of the interface can be selected at runtime by
correct derived class.

C++ program can have many different Abstract classes.

See abstract data types for C language details.

To learn desing of classes see here:

http://groups.google.com/group/comp...d7d6535/106fd67b957cf34b#doc_848d7705920c8533
and next message
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top