Connecting Tech Pros Worldwide Help | Site Map

abstract class

sam_cit@yahoo.co.in
Guest
 
Posts: n/a
#1: Jan 6 '07
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

Ondra Holub
Guest
 
Posts: n/a
#2: Jan 6 '07

re: abstract class



sam_cit@yahoo.co.in napsal:
Quote:
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.

andrewmcdonagh
Guest
 
Posts: n/a
#3: Jan 6 '07

re: abstract class




On Jan 6, 1:11 pm, sam_...@yahoo.co.in wrote:
Quote:
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

Jim Langston
Guest
 
Posts: n/a
#4: Jan 6 '07

re: abstract class


<sam_cit@yahoo.co.inwrote in message
news:1168089071.939953.252640@42g2000cwt.googlegro ups.com...
Quote:
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.


Daniel T.
Guest
 
Posts: n/a
#5: Jan 6 '07

re: abstract class


sam_cit@yahoo.co.in wrote:
Quote:
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?
http://www.objectmentor.com/resources/articles/ocp.pdf
Grizlyk
Guest
 
Posts: n/a
#6: Jan 12 '07

re: abstract class


sam_cit@yahoo.co.in wrote:
Quote:
>
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....8d7705920c8533
and next message

Closed Thread