473,326 Members | 2,813 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Abstract and concrete classes in c++

What are abstract classes and concrete classes
Jul 23 '05 #1
7 1654

Anitha wrote:
What are abstract classes and concrete classes


An abstract class is one which defines an interface, but it may not
provide implementations for all its member functions. Generally an
abstract class is used as the base class from which other classes are
derived. The derived class provides implementations for the member
functions that are not implemented in the base class.
A derived class that implements all the missing functionality is called
a concrete class

Jul 23 '05 #2
A concrete class is used to define a useful object that can be
instantiated as an automatic variable on the program stack. The
implementation of a concrete class is defined. The concrete class is
not intended to be a base class and no attempt to minimize dependency
on other classes in the implementation or behavior of the class

Jul 23 '05 #3

Anitha wrote:
What are abstract classes and concrete classes

Get a good C++ book and study it before posting...

Jul 23 '05 #4

<ta*************@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
A concrete class is used to define a useful object that can be
instantiated as an automatic variable on the program stack. The
implementation of a concrete class is defined. The concrete class is
not intended to be a base class


No, this is not true ... concrete classes can certainly be used as base
classes in a properly designed C++ program. A concrete class typically
represents an particular implementation of the concepts expressed in a given
abstract interface class. However, it may be appropriate to implement only
part of the interface in a particular concrete class, which will then be
used as a base class for types further down the hierarchy. It all depends
on what you want to do.

Advice to the OP: google the subject line, and then check out the book
reviews at www.accu.org and buy a book to help you further.

HTH,

Dave Moore
Jul 23 '05 #5
Dave Moore wrote:

[ ... ]
No, this is not true ... concrete classes can certainly be used as base classes in a properly designed C++ program.


How do you implement operator= safely for this situation?

--
Later,
Jerry.

The universe is a figment of its own imagination.

Jul 23 '05 #6

"Jerry Coffin" <jc*****@taeus.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Dave Moore wrote:

[ ... ]
No, this is not true ... concrete classes can certainly be used as

base
classes in a properly designed C++ program.


How do you implement operator= safely for this situation?
Jerry.


I'm lost as to what you're trying to get at here. What problem do you
foresee with implementing the = operator for non-abstract classes? I have
many classes that have no pure virtual functions. Yet I implement the =
operator wherever I need it. How are the two issues related?

-Howard

Jul 23 '05 #7

"Jerry Coffin" <jc*****@taeus.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Dave Moore wrote:

[ ... ]
No, this is not true ... concrete classes can certainly be used as

base
classes in a properly designed C++ program.


How do you implement operator= safely for this situation?


Well, if your base class has a copy assignment that can throw, then you
cannot write a copy-assignment operator that satisfies the "strong
guarantee" wrt exception safety. There is of course also a item in Scott
Meyers "More Effective C++" entitled "Make all non-leaf classes abstract",
which refutes my claim. So, I probably over-qualified my initial statement
by saying "properly designed C++ program", because strong exception safety
might be a requirement for "proper design" in many cases.

The fact is that I myself do not require the strong guarantee for my own
applications (scientific, numerical programs for which I am currently the
only user), and so I don't always think in terms of strong exception safety.
I will consider myself reprimanded 8*).

Actually this brings up a question ... If all of the data members in a class
(including any base classes) are statically allocated objects of built-in
type (i.e. no pointers or ctors), then does the implicitly generated copy
assignment operator implicitly provide the strong guarantee? Or even
better, the no-throw guarantee? It seems like it should, because the "only
thing that can go wrong" during construction in such a case is a stack
overflow (in which case we are dead anyway), or am I oversimplifying things.

Dave Moore
Jul 23 '05 #8

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

Similar topics

9
by: Christian Christmann | last post by:
Hi, I've a class Handler which contains a STL list std::list<Abstract*> mAbstract; which is storing elements of the abstract class Abstract. Further this class has a getElement function to...
2
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...
3
by: Magne Ryholt | last post by:
I have a base class and a chain of derived classes. The base and its derived classes are all abstract except the last in chain (a concrete class). I want to provide some functionalities in the...
6
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...
2
by: Julia | last post by:
Hi, I have an application composed from layers like the following A --B ---C A is the top layer C uses an Abstract Factory to Create Concrete classes
9
by: Sean Kirkpatrick | last post by:
To my eye, there doesn't seem to be a whole lot of difference between the two of them from a functional point of view. Can someone give me a good explanation of why one vs the other? Sean
6
by: Steve | last post by:
I am designing a new class hierarchy and I've already run into a bit of a bump in the road. I have this structure so far; class CodeGen class CodeGenHeader : CodeGen class CodeGenProtocolHeader...
8
by: Manuel | last post by:
Hi! If I've a vector filled with abstract classes, can I push in it the derived classes too? Even if derived classes have new methods? I've done some experiments, and it seem I can push the...
7
by: tron.thomas | last post by:
Please consider the following code: class Abstract { public: virtual ~Abstract() {} virtual void Method() = 0; }; class Concrete : public virtual Abstract
0
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...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.