473,379 Members | 1,511 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,379 software developers and data experts.

pure virtual class

Hi, gurus

The Ctor & Dtor of pure virtual class (interface class) should be

IMyClass() = 0;
or
IMyClass() { }

Thank in advance

Prawit C.

Jul 23 '05 #1
4 2250
Prawit Chaivong wrote:
The Ctor & Dtor of pure virtual class (interface class) should be

IMyClass() = 0;
or
IMyClass() { }


First of all, there is no such thing as "pure virtual class". There is
an 'abstract class', maybe you meant to use that term? I'll assume so.
To answer what I think was your question, (a) you cannot make a c-tor
pure by adding "=0" to it because c-tors cannot be virtual and only the
virtual members can be declared pure, and (b) as to the d-tor, it's up
to you, but remember that even if you do declare the d-tor pure, you still
need to provide an [empty] implementation, since it's definitely going to
be called.

V
Jul 23 '05 #2
> Hi, gurus

The Ctor & Dtor of pure virtual class (interface class) should be

IMyClass() = 0;
or
IMyClass() { }

Thank in advance

Prawit C.


Homework?

You could at least search the newsgroup to determine the answer for
yourself. Also, maybe you should read your text book.

Jul 23 '05 #3

"Prawit Chaivong" <pr******@gmail.com> wrote in message
news:11*********************@g43g2000cwa.googlegro ups.com...
Hi, gurus

The Ctor & Dtor of pure virtual class (interface class) should be

IMyClass() = 0;
or
IMyClass() { }

Thank in advance

Prawit C.


An abstract class's ctor and dtor can't be pure-virtual. The logic is
simple: a derived class can't overide / overload base class ctor(s) or
d~tor. This is true whether the base is abstract or not.

Now you know why you can't "call", but only "invoke", a base ctor or d~tor.

Jul 23 '05 #4
Peter Julian wrote:
"Prawit Chaivong" <pr******@gmail.com> wrote in message
news:11*********************@g43g2000cwa.googlegro ups.com...
Hi, gurus

The Ctor & Dtor of pure virtual class (interface class) should be

IMyClass() = 0;
or
IMyClass() { }

Thank in advance

Prawit C.

An abstract class's ctor and dtor can't be pure-virtual. The logic is
simple: a derived class can't overide / overload base class ctor(s) or
d~tor. This is true whether the base is abstract or not.

Now you know why you can't "call", but only "invoke", a base ctor or d~tor.


I can call the d-tor without any problem. I can even call it for
an int or a double. Didn't you know?

V
Jul 23 '05 #5

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

Similar topics

11
by: santosh | last post by:
Hello, I was going through the Marshal Cline's C++ FAQ-Lite. I have a doubt regarding section 33.10. Here he is declaring a pure virtual destructor in the base class. And again defining...
37
by: WittyGuy | last post by:
Hi, I wonder the necessity of constructor and destructor in a Abstract Class? Is it really needed? ? Wg http://www.gotw.ca/resources/clcm.htm for info about ]
6
by: pakis | last post by:
I am having a problem of pure virtual function call in my project. Can anyone explaine me the causes of pure virtual function calls other than calling a virtual function in base class? Thanks
3
by: sudhir | last post by:
I defined a pure virtual function like virtual void sum()=0; <--- pure virtual function but If I defined a virtual function in a base class in case of multilevel inheritance for the base...
21
by: sks | last post by:
Hi , could anyone explain me why definition to a pure virtual function is allowed ?
10
by: John Goche | last post by:
Hello, page 202 of Symbian OS Explained by Jo Stichbury states "All virtual functions, public, protected or private, should be exported" then page 203 states "In the rare cases where a...
7
by: sam_cit | last post by:
Hi Everyone, I wanted to know as to what is the exact difference between a virtual function and a pure virtual function? Thanks in advance!!!
6
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...
14
by: Jack | last post by:
Hi, I meet a question with it , I did not get clear the different betteen them, for example: #include <iostream>
7
by: Tonni Tielens | last post by:
I'm trying to create a pure virtual class describing an interface. Normally, when I do this I make the destructor pure virtual so that, even if there are no members in the class, it cannot be...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.