472,992 Members | 3,526 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,992 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 2595

"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
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...
3
SueHopson
by: SueHopson | last post by:
Hi All, I'm trying to create a single code (run off a button that calls the Private Sub) for our parts list report that will allow the user to filter by either/both PartVendor and PartType. On...

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.