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

using declaration question

Why can't I use a class destructor in a using declaration:

using MyClass::~MyClass;

?

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Jul 22 '05 #1
10 2619

"Christopher Benson-Manica" <at***@nospam.cyberspace.org> wrote in
message news:c1**********@chessie.cirr.com...
Why can't I use a class destructor in a using declaration:

using MyClass::~MyClass;


Interesting question! It seems to be allowed by the grammar; it may be
illegal for some other reason, however.

VC7.1 is the only compiler I've tried which accepts it.

Jonathan
Jul 22 '05 #2
Christopher Benson-Manica wrote:

Why can't I use a class destructor in a using declaration:

using MyClass::~MyClass;


Because destructors, like constructors, do not have names, and a using
declaration requires a name.

--

Pete Becker
Dinkumware, Ltd. (http://www.dinkumware.com)
Jul 22 '05 #3

"Christopher Benson-Manica" <at***@nospam.cyberspace.org> wrote in message
news:c1**********@chessie.cirr.com...
Why can't I use a class destructor in a using declaration:

using MyClass::~MyClass;


================================================== ==================
ISO/IEC 14882:1998(E)

7.3.3 The using declaration

4 A using*-declaration used as a member*-declaration shall refer
to a member of a base class of the class being defined, shall
refer to a member of an anonymous union that is a member of a
base class of the class being defined, or shall refer to an
enumerator for an enumeration type that is a member of a base
class of the class being defined. [Example:

class C {
int g();
};

class D2 : public B {
using B::f; // OK: B is a base of D2
using B::e; // OK: e is an enumerator of base B
using B::x; // OK: x is a union member of base B
using C::g; // error: C isn’t a base of D2
};

--end example] [Note: since constructors and destructors do not
have names, a using*-declaration cannot refer to a constructor <<=====
or a destructor for a base class. Since specializations of member
templates for conversion functions are not found by name lookup,
they are not considered when a using*-declaration specifies a
conversion function (14.5.2). ] If an assignment operator brought
from a base class into a derived class scope has the signature of
a copy*-assignment operator for the derived class (12.8), the using*-
declaration does not by itself suppress the implicit declaration
of the derived class copy*-assignment operator; the copy*-assignment
operator from the base class is hidden or overridden by the
implicitly*-declared copy*-assignment operator of the derived class,
as described below.
================================================== ==================
-Mike

Jul 22 '05 #4

"Jonathan Turkanis" <te******@kangaroologic.com> wrote in message
news:c1*************@ID-216073.news.uni-berlin.de...

"Christopher Benson-Manica" <at***@nospam.cyberspace.org> wrote in
message news:c1**********@chessie.cirr.com...
Why can't I use a class destructor in a using declaration:

using MyClass::~MyClass;

Interesting question! It seems to be allowed by the grammar; it may be
illegal for some other reason, however.


Yes, see 7.3.3.4

VC7.1 is the only compiler I've tried which accepts it.


Baaad Microsoft! :-)

-Mike
Jul 22 '05 #5

"Mike Wahler" <mk******@mkwahler.net> wrote in message
news:UC*****************@newsread2.news.pas.earthl ink.net...

"Jonathan Turkanis" <te******@kangaroologic.com> wrote in message
news:c1*************@ID-216073.news.uni-berlin.de...

"Christopher Benson-Manica" <at***@nospam.cyberspace.org> wrote in
message news:c1**********@chessie.cirr.com...
Why can't I use a class destructor in a using declaration:

using MyClass::~MyClass;


Interesting question! It seems to be allowed by the grammar; it may be illegal for some other reason, however.


Yes, see 7.3.3.4


That'll teach me to skip over notes!

Jonathan
Jul 22 '05 #6
Mike Wahler <mk******@mkwahler.net> spoke thus:
7.3.3 The using declaration snip lovely quote from Standard


Ah, a quote from the Standard - thank you :) (even though it has now
obliterated all my hopes and dreams...) So here's my SUPER question:
How can I reconcile conflicting destructor declarations when multiply
inheriting, which I WOULD do with using; if that old wolf Stroustrup
hadn't forbidden it...? *sigh*

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Jul 22 '05 #7
"Christopher Benson-Manica" <at***@nospam.cyberspace.org> wrote in message
news:c1**********@chessie.cirr.com...
Mike Wahler <mk******@mkwahler.net> spoke thus:
7.3.3 The using declaration
snip lovely quote from Standard


Ah, a quote from the Standard - thank you :) (even though it has now
obliterated all my hopes and dreams...)


Please don't shoot the messenger. :-)
So here's my SUPER question:
How can I reconcile conflicting destructor declarations when multiply
inheriting, which I WOULD do with using; if that old wolf Stroustrup
hadn't forbidden it...? *sigh*


Sorry, I'm a MI 'virgin', hopefully one of the gurus can help.

I am watching your little 'project' with interest.
Have you visited Dietmar's web site?

-Mike
Jul 22 '05 #8

"Christopher Benson-Manica" <at***@nospam.cyberspace.org> wrote in
message news:c1**********@chessie.cirr.com...
Mike Wahler <mk******@mkwahler.net> spoke thus: Ah, a quote from the Standard - thank you :) (even though it has now
obliterated all my hopes and dreams...) So here's my SUPER question: How can I reconcile conflicting destructor declarations when multiply inheriting, which I WOULD do with using; if that old wolf Stroustrup
hadn't forbidden it...? *sigh*


If you're not planning on calling the destructors explicitly, you
don't need to reconcile them. If you want to call one explicitly, you
can qualify it with its namespace or enclosing class.

What are you trying to do?

Jonathan
Jul 22 '05 #9
Jonathan Turkanis <te******@kangaroologic.com> spoke thus:
If you're not planning on calling the destructors explicitly, you
don't need to reconcile them.
Well, only one of them is virtual, so my compiler has been
complaining... At any rate, there is *something* amiss, although it
could be my fault ;)
What are you trying to do?


Not go insane...

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Jul 22 '05 #10
Christopher Benson-Manica <at***@nospam.cyberspace.org> wrote in message news:<c1**********@chessie.cirr.com>...
Why can't I use a class destructor in a using declaration:

using MyClass::~MyClass;

?


Because the child class has another name. The name of the destructor is
always the name of the class. To build the call chain of destructors the
compiler needs a destructor in the parent and the child class.

Ralf

www.oop-trainer.de
Jul 22 '05 #11

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

Similar topics

83
by: Alexander Zatvornitskiy | last post by:
Hello All! I'am novice in python, and I find one very bad thing (from my point of view) in language. There is no keyword or syntax to declare variable, like 'var' in Pascal, or special syntax in...
1
by: Ken Larson | last post by:
I have a question about using XSL to extract information from an SVG (XML) file that has a DOCTYPE/DTD declaration. I am able to do this successfully if I write my own SVG files without such a...
4
by: Marshall Mills | last post by:
As I understand it, loaded statement, a using declaration should be all I need to see an enum from within a namespace. The below code works fine with class, struct, and union. What gives? As the...
14
by: john.burton.email | last post by:
I've done some extensive searching and can't seem to find an answer to this - Is it correct to using "using" with templates, for example: using std::vector; Or do I need to specify the type...
3
by: Dan | last post by:
Is there a better way to include the XML declaration than the following? XmlDeclaration dec =m_XMLDocument.CreateXmlDeclaration("1.0",string.Empty, "yes");...
10
by: Kobu | last post by:
My question is about the use and meaning of the terms "declaration" and "definition" as it pertains to the C language. I've read sources that mix the two up when talking about such things as...
9
by: Michael Mair | last post by:
Hello, in C89 (at least in the last public draft), "3.6.2 Compound statement, or block", we have ,--- | Syntax | | compound-statement: | { ...
4
by: Ray Dukes | last post by:
What I am looking to do is map the implementation of interface properties and functions to an inherited method of the base class. Please see below. ...
12
by: Speed | last post by:
Hi, Could you please tell me what is the simplest code to read a 8-bit grayscale JPEG using C++? Thanks a ton, Speed.
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:
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
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,...
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...
0
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...

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.