By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,421 Members | 1,128 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,421 IT Pros & Developers. It's quick & easy.

Abstract Class

P: n/a
Hi

Been reading the GOF book and started to make the distinction between
Class and Interface inheritance. One question though:

Do pure abstract classes have representations? (data members?)
What about abstract classes?

Should abstract classes have a destructor and or constructor? What
about pure abstract classes?

What are the conditions that must be satisfied for a class to be

A) Pure Abstract class
B) Abstract Class

Regards

Merlin
Jul 22 '05 #1
Share this Question
Share on Google+
16 Replies


P: n/a

"Merlin" <me********@hotmail.com> wrote in message
news:12**************************@posting.google.c om...
Hi

Been reading the GOF book and started to make the distinction between
Class and Interface inheritance. One question though:

Do pure abstract classes have representations? (data members?)
What about abstract classes?
I wouldn't try to make a big deal out of the difference. I don't think
there is any such thing as "pure abstract class" in the strict C++ sense (I
doubt it's mentioned in the standard - could be wrong.) The point is that
abstract classes might or might not have data. If any abstract class has no
data, some people call that a pure abstract class. I guess that distinction
is made by people who it never occurred to that you could do that.
Should abstract classes have a destructor and or constructor? What
about pure abstract classes?
Of course if there is no data, or "state", then there is no reason to have a
constructor or destructor. Of course there can be exceptions - an abstract
class might still have a base class, for example.
What are the conditions that must be satisfied for a class to be

A) Pure Abstract class
B) Abstract Class


B) it should have a pure virtual function. A) there really isn't one, other
than the fact that most people consider an abstract class with no function
to be "pure" ("pure" interface, that is.) (I'm talking about C++ of course.
I don't know if GoF refers to "pure abstract class" in a more general
context with a more specific definition.)
Jul 22 '05 #2

P: n/a
Merlin wrote:
Hi

Been reading the GOF book and started to make the distinction between
Class and Interface inheritance. One question though:

Do pure abstract classes have representations? (data members?)
No. "pure abstract class" is typically used to mean a class with nothing
but pure virtual functions (i.e. no function implementations, no data).
What about abstract classes?
I'm not sure if there is any official definition for this, but any class
that contains at least one pure virtual function, and thus cannot be
directly instantiated, would be abstract. Since it cannot be
instantiated, talking about whether it has any representation if fairly
meaningless.

Should abstract classes have a destructor and or constructor? What
about pure abstract classes?
I can't think of any reason why a constructor would be required. Having
a virtual destructor, however, is important if you ever expect an object
to be deleted via a pointer to the abstract base class.
What are the conditions that must be satisfied for a class to be

A) Pure Abstract class
B) Abstract Class
See above.

Regards

Merlin


Alan
Jul 22 '05 #3

P: n/a
Merlin wrote:
Been reading the GOF book and started to make the distinction between
Class and Interface inheritance. One question though:
One? Really?

Do pure abstract classes have representations? (data members?)
Some do, some don't. Up to you.
What about abstract classes?
What about them?
Should abstract classes have a destructor and or constructor? What
about pure abstract classes?
They should when needed.
What are the conditions that must be satisfied for a class to be

A) Pure Abstract class
B) Abstract Class


Homework questions should be answered by reading your textbook.
Jul 22 '05 #4

P: n/a
Victor Bazarov wrote:

Merlin wrote:
Been reading the GOF book and started to make the distinction between
Class and Interface inheritance. One question though:


One? Really?

Do pure abstract classes have representations? (data members?)


Some do, some don't. Up to you.
What about abstract classes?


What about them?
Should abstract classes have a destructor and or constructor? What
about pure abstract classes?


They should when needed.
What are the conditions that must be satisfied for a class to be

A) Pure Abstract class
B) Abstract Class


Homework questions should be answered by reading your textbook.


What is the purpose of such senseless non-responses and blind assumptions?
Jul 22 '05 #5

P: n/a
Julie wrote:
Victor Bazarov wrote:
Merlin wrote:
Been reading the GOF book and started to make the distinction between
Class and Interface inheritance. One question though:


One? Really?

Do pure abstract classes have representations? (data members?)


Some do, some don't. Up to you.

What about abstract classes?


What about them?

Should abstract classes have a destructor and or constructor? What
about pure abstract classes?


They should when needed.

What are the conditions that must be satisfied for a class to be

A) Pure Abstract class
B) Abstract Class


Homework questions should be answered by reading your textbook.

What is the purpose of such senseless non-responses and blind assumptions?


I'm sorry. This is not the appropriate newsgroup in which to ask your
philosophy homework questions.

:-)

Alan
Jul 22 '05 #6

P: n/a

"Julie" <ju***@nospam.com> wrote in message
news:40***************@nospam.com...
Victor Bazarov wrote:

Merlin wrote:
Been reading the GOF book and started to make the distinction between
Class and Interface inheritance. One question though:


One? Really?

Do pure abstract classes have representations? (data members?)


Some do, some don't. Up to you.
What about abstract classes?


What about them?
Should abstract classes have a destructor and or constructor? What
about pure abstract classes?


They should when needed.
What are the conditions that must be satisfied for a class to be

A) Pure Abstract class
B) Abstract Class


Homework questions should be answered by reading your textbook.


What is the purpose of such senseless non-responses and blind assumptions?


C'mon, Julie...

look at those questions! Who but an instructor or test writer would
write questions like that? Seriously, do you think that anyone would ever
actually have come up with those questions out of curiosity? Also, the post
comes via news.maxwell.syr.edu, which sure looks like a school site to me.
I have seen that you like to defend others against this kind of assumption,
which is, I suppose, laudable. But this looks very much like homework to
me, (and to Victor also, apparently). And this is not the place to get your
homework done by others.

What is the purpose? To shame them into doing their own work, I
suppose.

-Howard


Jul 22 '05 #7

P: n/a
Julie wrote:
Victor Bazarov wrote:
Homework questions should be answered by reading your textbook.


What is the purpose of such senseless non-responses and blind assumptions?


Victor is "burnt out" again.
He answers new subscribers' questions politely and cheerfully
for months on end then he descends into these dark little episodes.
Take a break Victor.

But I agree with Victor.
I think Merlin has posted homework questions.
We don't mind helping people with their homework
but we don't want to frustrate their instructors either.
Merlin will get lots of help (even from Victor)
if he will attempt to answer the questions himself first.

Jul 22 '05 #8

P: n/a
Howard wrote:

"Julie" <ju***@nospam.com> wrote in message
news:40***************@nospam.com...
Victor Bazarov wrote:

Merlin wrote:
> Been reading the GOF book and started to make the distinction between
> Class and Interface inheritance. One question though:

One? Really?

>
> Do pure abstract classes have representations? (data members?)

Some do, some don't. Up to you.

> What about abstract classes?

What about them?

> Should abstract classes have a destructor and or constructor? What
> about pure abstract classes?

They should when needed.

> What are the conditions that must be satisfied for a class to be
>
> A) Pure Abstract class
> B) Abstract Class

Homework questions should be answered by reading your textbook.


What is the purpose of such senseless non-responses and blind assumptions?


C'mon, Julie...

look at those questions! Who but an instructor or test writer would
write questions like that? Seriously, do you think that anyone would ever
actually have come up with those questions out of curiosity? Also, the post
comes via news.maxwell.syr.edu, which sure looks like a school site to me.
I have seen that you like to defend others against this kind of assumption,
which is, I suppose, laudable. But this looks very much like homework to
me, (and to Victor also, apparently). And this is not the place to get your
homework done by others.

What is the purpose? To shame them into doing their own work, I
suppose.

-Howard


I've said it before, and I'll continue to say it: answer the question asked,
give the poster the credibility to be able to ask questions for the answers
they desire, and stop w/ the assumptions.

Regardless of your ideas about the motivations of the original poster, the
questions have value and merit discussion in the forum. If a respondent
doesn't have anything constructive to add (such as was the case w/ Victor's
response), move on; the senseless blather provides absolutely no benefit to the
community.
Jul 22 '05 #9

P: n/a
"Howard" <al*****@hotmail.com> wrote in message
news:r_*********************@bgtnsc05-news.ops.worldnet.att.net...
> What are the conditions that must be satisfied for a class to be
>
> A) Pure Abstract class
> B) Abstract Class

Homework questions should be answered by reading your textbook.
What is the purpose of such senseless non-responses and blind

assumptions?
C'mon, Julie...

look at those questions! Who but an instructor or test writer would
write questions like that?


They might be homework, but now I'm curious. Abstract classes I know, but
"pure abstract classes" I haven't come across. I would have guessed that
"pure" somehow came across from "pure virtual" and is redundant or
inappropriate. Or is a "pure abstract class" one that contains nothing but
an interface of pure virtuals? If so, "pure abstract" sounds more like an OO
term than a C++ term.

DW

Jul 22 '05 #10

P: n/a
"David White" <no@email.provided> wrote
They might be homework, but now I'm curious. Abstract classes I know, but
"pure abstract classes" I haven't come across. I would have guessed that
"pure" somehow came across from "pure virtual" and is redundant or
inappropriate. Or is a "pure abstract class" one that contains nothing but
an interface of pure virtuals? If so, "pure abstract" sounds more like an OO
term than a C++ term.


You can have pure virtual functions and you can have abstract base classes. You
can't have pure abstract classes. That's just someone mingling unrelated
concepts. Those who do are usually trying to attach a name to a class that has
only pure virtual functions. This, of course, is clearly impossible because every
class must have at least one constructor -- either explicitly or implicitly
defined -- if it's to be instantiated or inherited from and constructors cannot
be virtual. Some add to this fabricated definition that the so-called "pure
abstract class" can have no data members. Others try to call it an interface.
Since these terms are bogus to start with in the context of C++, it's really
irrelevant what rules anyone tries to impose on them. :-)

This is actually symptomatic of something that we see fairly often: some people
are uncomfortable with the vast number of combinations that C++ offers and try to
label and compartmentalize specific combinations. Once an arbitrary combination
has been named, these people feel more secure in criticizing code that falls
outside their little subset of absorbed concepts by saying things like, "You're
doing that wrong. You should be using a pure virtual abstract ethereal diaphanous
base class as described in the 'Horde of Sixty-Two' book."

Claudio Puviani
Jul 22 '05 #11

P: n/a
Julie wrote:
Victor Bazarov wrote:
Merlin wrote:
Been reading the GOF book and started to make the distinction between
Class and Interface inheritance. One question though:


One? Really?

Do pure abstract classes have representations? (data members?)


Some do, some don't. Up to you.

What about abstract classes?


What about them?

Should abstract classes have a destructor and or constructor? What
about pure abstract classes?


They should when needed.

What are the conditions that must be satisfied for a class to be

A) Pure Abstract class
B) Abstract Class


Homework questions should be answered by reading your textbook.

What is the purpose of such senseless non-responses and blind assumptions?


Victor answered the meaningful questions correctly and concisely.
Jul 22 '05 #12

P: n/a

"David White" <no@email.provided> wrote in message
news:Dm********************@nasal.pacific.net.au.. .

They might be homework, but now I'm curious. Abstract classes I know, but
"pure abstract classes" I haven't come across. I would have guessed that
"pure" somehow came across from "pure virtual" and is redundant or
inappropriate. Or is a "pure abstract class" one that contains nothing but
an interface of pure virtuals? If so, "pure abstract" sounds more like an OO term than a C++ term.


It is. And of course C++ is an OO language, so there's nothing wrong with
OO terminology.
Jul 22 '05 #13

P: n/a
It is quite amazing how people can make assumptions and believe that
it is true. I am afraid you were wrong. Also the origin of the post is
not news.maxwell.syr.edu as I live in the UK. But if it makes you
happy you can make further assumptions and feel that you are right.

The motivation behind those questions (yes there was more than one)
came from reading the GOF book. I wanted to understand the difference
between Interface and class inheritance. If you look on pages 16-18
you will see that abstract classes (pure or otherwise) mentioned. A
pure interface inheritance is said to be approximated in C++ by
inheriting publicly from a pure abstract class. So I wanted to know
what a pure abstract class was in c++.

You can be proud of your achievement of polluting this thread of
discussion.

Well done!
Jul 22 '05 #14

P: n/a
Merlin wrote:
It is quite amazing how people can make assumptions and believe that
it is true. I am afraid you were wrong. Also the origin of the post is
not news.maxwell.syr.edu as I live in the UK. But if it makes you
happy you can make further assumptions and feel that you are right.

The motivation behind those questions (yes there was more than one)
came from reading the GOF book. I wanted to understand the difference
between Interface and class inheritance. If you look on pages 16-18
you will see that abstract classes (pure or otherwise) mentioned. A
pure interface inheritance is said to be approximated in C++ by
inheriting publicly from a pure abstract class. So I wanted to know
what a pure abstract class was in c++.

You can be proud of your achievement of polluting this thread of
discussion.

Well done!


This seems to be a direct response to my brief message, although it does
not appear here... Is all of this vitriol actually directed at me?
Jul 22 '05 #15

P: n/a
Who but an instructor or test writer would
write questions like that? Seriously, do you think that anyone would ever
actually have come up with those questions out of curiosity? Also, the post
comes via news.maxwell.syr.edu, which sure looks like a school site to me.


Yes,

but finals were over two weeks ago at Syracuse...

If they are designing a test, it would be nice to have the input from
"experts".

If it's a student trying to learn (not to cheat), what's the harm?

If you feel this is inappropriate, you don't need to answer.

Let others post whatever they want. It's their problem...

JLR
Jul 22 '05 #16

P: n/a

"Jeff Schwab" <je******@comcast.net> wrote in message
news:xf********************@comcast.com...
Merlin wrote:
It is quite amazing how people can make assumptions and believe that
it is true. I am afraid you were wrong. Also the origin of the post is
not news.maxwell.syr.edu as I live in the UK. But if it makes you
happy you can make further assumptions and feel that you are right.

The motivation behind those questions (yes there was more than one)
came from reading the GOF book. I wanted to understand the difference
between Interface and class inheritance. If you look on pages 16-18
you will see that abstract classes (pure or otherwise) mentioned. A
pure interface inheritance is said to be approximated in C++ by
inheriting publicly from a pure abstract class. So I wanted to know
what a pure abstract class was in c++.

You can be proud of your achievement of polluting this thread of
discussion.

Well done!


This seems to be a direct response to my brief message, although it does
not appear here... Is all of this vitriol actually directed at me?


Nah, some of it was obviously directed at me (and Victor). I saw that .edu
address in the chain, which may or may not mean anything at all (a sender
usually has no control where it goes, especially when posted from
groups.google.com). I still say the questions sounded very much like
homework. It wouldn't have seemed so if Merlin had simply asked "what is a
pure abstract class in C++", to which he would have gotten the reply "there
is no such thing in C++...maybe you mean an abstract class with no members?"

(By the way Merlin, what makes you assume we know what the heck the "GOF
book" is, let alone have a copy of it?)

*Assuming* you're telling truth Merlin, then I apologize for the previously
incorrect assumptions.

-Howard

Jul 22 '05 #17

This discussion thread is closed

Replies have been disabled for this discussion.