473,799 Members | 3,005 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Abstract Class

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
16 3530
"David White" <no@email.provi ded> 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 compartmentaliz e 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
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

"David White" <no@email.provi ded> wrote in message
news:Dm******** ************@na sal.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
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.sy r.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
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.sy r.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
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.sy r.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

"Jeff Schwab" <je******@comca st.net> wrote in message
news:xf******** ************@co mcast.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.sy r.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.c om). 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2310
by: Tony Johansson | last post by:
Hello! Assume you have an abstract class called Body and a derived class called cylinder. When you have an abstract class you can't instansiate an object. As you can see in the abstract class there are one data member called density that you can't access because there will not be any object of class Body. The data member density will be inheritated and all the member functions. So when you have an instance of class Cylinder and you...
12
3099
by: Daedalus.OS | last post by:
Ok first I'm pretty new to OOP, so my question may sound stupid to some of you. If the only answer you can provide is "get a book about OOP" then don't loose your time and mine cause it's already ordered. I'm just too curious about this one to wait for the book. I would like to know is if it's good php programming practice to use abstract classes instead of singleton classes. For exemple a login class. I've made one as an abstract class...
2
9609
by: Dave Veeneman | last post by:
Is is legal to declare abstract members in non-abstract classes? How about non-abstract members in abstract classes? I am writing a base class with three derived classes. The base class will define the behavior for most, but not all of its members. The derived classes will define the behavior for the remaining members (the undefined members). I'd like to force the derived classes to implement the undefined members in the base class. I...
6
5804
by: Dan Sikorsky | last post by:
If we were to define all abstract methods in an abstract class, thereby making that class non-abstract, and then override the heretofore 'abstract' methods in a derived class, wouldn't that remove the need to have abstract class types in C#? Derived classes from abstract base classes must overrided the abstract method defininition anyway, so why not just provide a complete definition for the abstract method when defining the containing...
7
4476
by: jason | last post by:
In the microsoft starter kit Time Tracker application, the data access layer code consist of three cs files. DataAccessHelper.cs DataAcess.cs SQLDataAccessLayer.cs DataAcccessHelper appears to be checking that the correct data type is used DataAcess sets an abstract class and methods
0
2681
by: mailforpr | last post by:
Hi. Let me introduce an iterator to you, the so-called "Abstract Iterator" I developed the other day. I actually have no idea if there's another "Abstract Iterator" out there, as I have never looked for one on the net (I did browse the boost library though). It doesn't matter right now, anyway. To put it simply, Abstract Iterator is mainly a wrapper class. It helps
4
3207
by: N.RATNAKAR | last post by:
hai, what is abstract class and abstract method
0
2839
by: emin.shopper | last post by:
I had a need recently to check if my subclasses properly implemented the desired interface and wished that I could use something like an abstract base class in python. After reading up on metaclass magic, I wrote the following module. It is mainly useful as a light weight tool to help programmers catch mistakes at definition time (e.g., forgetting to implement a method required by the given interface). This is handy when unit tests or...
4
6570
by: David Zha0 | last post by:
Hi, "when we call a virtual method, the runtime will check the instance who called the method and then choose the suitable override method, this may causes the performance drop down", is this right? And, why not use "new" instead of using "virtual"? And the last question, what is the differences between a abstract method and a interface?
6
4035
by: Miguel Guedes | last post by:
Hello, I recently read an interview with Bjarne Stroustrup in which he says that pure abstract classes should *not* contain any data. However, I have found that at times situations are when it would be useful to have /some/ data defined in such an abstract class for reasons of forming a common block of data existing in or used by all descendant classes (see example below.) In such a case where a common block of data *always* exists,...
0
9687
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10482
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10251
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
10225
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,...
0
9072
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7564
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
6805
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();...
1
4139
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3759
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.