473,396 Members | 2,011 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,396 software developers and data experts.

what is the difference between abstract class and pure abstract class?

and what is object delagation, and how it can implemented?

May 16 '06 #1
4 3896
sk*******@yahoo.co.in wrote:
and what is object delagation, and how it can implemented?


There is no concept of "pure abstract class" in C++. So, I'd say there
is no difference. Of course, one could always pull some concept by the
ears and say that a "pure abstract class" is an abstract class that has
no data members. Is that good enough to deduce the difference?

Have you tried searching the web for "pure abstract class" and "object
delegation" (yes, it's spelled a bit differently)? If not, what is
stopping you? If you did, what have you found? Is there something in
those web pages you don't understand? "Delegation" is implemented in
C++ through inheritance or containment. Slap polymorphism on top of
it and you get a very powerful run-time mechanism for extending object's
functionality.
V
--
Please remove capital As from my address when replying by mail
May 16 '06 #2

Victor Bazarov wrote:
sk*******@yahoo.co.in wrote:
and what is object delagation, and how it can implemented?


There is no concept of "pure abstract class" in C++. So, I'd say there
is no difference. Of course, one could always pull some concept by the
ears and say that a "pure abstract class" is an abstract class that has
no data members. Is that good enough to deduce the difference?


A pure abstract class is an abstract class with no implemented members.

class Abstract
{
public:
virtual void f1() = 0;
virtual void f2() {}
};

class PureAbstract
{
public:
virtual void f1() = 0;
virtual void f2() = 0;
};

The "pure abstract" is really nothing but an interface def.

It seems like a silly distinction but there are arguments against the
first version in favor of always doing the second. The language makes
no such distinction...it is purely a design issue.

Not sure if a "pure abstract" has data members...I think not.

May 16 '06 #3
sk*******@yahoo.co.in wrote:
and what is object delagation, and how it can implemented?


Please always put the complete question into the body. I was quite irritated
by the "and" at the beginning, until I saw that the subject line already
contains another question.

An abstract class is one that has at least one pure virtual member and thus
can't be instantiated directly. There is no such thing as "pure abstract
class" in C++.
Delegation means that an object doesn't handle a request, but rather
delegates it to another special handler object. This way, you can plug
different handlers to your object to get different behavior.

May 16 '06 #4
Noah Roberts wrote:
A pure abstract class is an abstract class with no implemented members.

class Abstract
{
public:
virtual void f1() = 0;
virtual void f2() {}
};

class PureAbstract
{
public:
virtual void f1() = 0;
virtual void f2() = 0;
};

The "pure abstract" is really nothing but an interface def.

It seems like a silly distinction but there are arguments against the
first version in favor of always doing the second.


IMHO, it's a big advantage of C++ over some other modern OO languages that
it actually permits the first version. Sometimes, I want an abstract class,
but I sill want some stuff implemented there. Otherwise all derived class
would have to implement the same behavior over and over again. That would
result in code duplication.
May 17 '06 #5

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

Similar topics

4
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...
2
by: Tony Johansson | last post by:
Hello! I'm reading in a book about C++ and they say that the class definition below is abstract is that really true. The definition of a class to be abstract is when at least one member is...
11
by: Shea Martin | last post by:
I have been programming in C++ for over 4 years. I *think* I knew that a struct could have a constructor but I decided to dig into it a little more today, and found that there is very little...
3
by: WithPit | last post by:
I am trying to create an managed wrapper but have some problems with it by using abstract classes. In my unmanaged library code i had the following three classes with the following hierarchy ...
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
4
by: sudhir | last post by:
Q 1. I defined a class with 10 functions . It contains declaration of 5 functions and 5 functions are declared and defined. Is this class is said to a abstract class ? Q 2. Which one is...
4
by: Raja Chandrasekaran | last post by:
Hai friends, I really wonder, If the interface does not have any definition, Y do we need to use interface. You can then only we can use Multiple inheritance. I really cant understand, Just for...
8
by: weird0 | last post by:
Can anyone explain briefly what is the difference between inheritance and polymorphism? i read and seem to forget it again and again... Can anyone along with good examples of c# explain the...
17
by: Jess | last post by:
Hello, If I have a class that has virtual but non-pure declarations, like class A{ virtual void f(); }; Then is A still an abstract class? Do I have to have "virtual void f() = 0;"...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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...

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.