C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

using declaration question

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++)
View previous topic :: View next topic  
Author Message
Christopher Benson-Manica
Guest





PostPosted: Thu Feb 26, 2004 7:48 pm    Post subject: using declaration question Reply with quote



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.
Back to top
Jonathan Turkanis
Guest





PostPosted: Thu Feb 26, 2004 8:15 pm    Post subject: Re: using declaration question Reply with quote




"Christopher Benson-Manica" <ataru (AT) nospam (DOT) cyberspace.org> wrote in
message news:c1lihi$504$1 (AT) chessie (DOT) cirr.com...
Quote:
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



Back to top
Pete Becker
Guest





PostPosted: Thu Feb 26, 2004 8:19 pm    Post subject: Re: using declaration question Reply with quote



Christopher Benson-Manica wrote:
Quote:

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)

Back to top
Mike Wahler
Guest





PostPosted: Thu Feb 26, 2004 8:24 pm    Post subject: Re: using declaration question Reply with quote


"Christopher Benson-Manica" <ataru (AT) nospam (DOT) cyberspace.org> wrote

Quote:
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:Mad; // 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.Cool, 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




Back to top
Mike Wahler
Guest





PostPosted: Thu Feb 26, 2004 8:25 pm    Post subject: Re: using declaration question Reply with quote


"Jonathan Turkanis" <technews (AT) kangaroologic (DOT) com> wrote

Quote:

"Christopher Benson-Manica" <ataru (AT) nospam (DOT) cyberspace.org> wrote in
message news:c1lihi$504$1 (AT) chessie (DOT) 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

Quote:

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

Baaad Microsoft! :-)

-Mike



Back to top
Jonathan Turkanis
Guest





PostPosted: Thu Feb 26, 2004 8:30 pm    Post subject: Re: using declaration question Reply with quote


"Mike Wahler" <mkwahler (AT) mkwahler (DOT) net> wrote

Quote:

"Jonathan Turkanis" <technews (AT) kangaroologic (DOT) com> wrote in message
news:c1lk2v$1jg271$1 (AT) ID-216073 (DOT) news.uni-berlin.de...

"Christopher Benson-Manica" <ataru (AT) nospam (DOT) cyberspace.org> wrote in
message news:c1lihi$504$1 (AT) chessie (DOT) 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



Back to top
Christopher Benson-Manica
Guest





PostPosted: Thu Feb 26, 2004 8:44 pm    Post subject: Re: using declaration question Reply with quote

Mike Wahler <mkwahler (AT) mkwahler (DOT) net> spoke thus:

Quote:
7.3.3 The using declaration

snip lovely quote from Standard

Ah, a quote from the Standard - thank you Smile (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.

Back to top
Mike Wahler
Guest





PostPosted: Thu Feb 26, 2004 9:10 pm    Post subject: Re: using declaration question Reply with quote

"Christopher Benson-Manica" <ataru (AT) nospam (DOT) cyberspace.org> wrote

Quote:
Mike Wahler <mkwahler (AT) mkwahler (DOT) net> spoke thus:

7.3.3 The using declaration

snip lovely quote from Standard

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

Please don't shoot the messenger. :-)

Quote:
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



Back to top
Jonathan Turkanis
Guest





PostPosted: Thu Feb 26, 2004 9:20 pm    Post subject: Re: using declaration question Reply with quote


"Christopher Benson-Manica" <ataru (AT) nospam (DOT) cyberspace.org> wrote in
message news:c1llrj$622$1 (AT) chessie (DOT) cirr.com...
Quote:
Mike Wahler <mkwahler (AT) mkwahler (DOT) net> spoke thus:

Ah, a quote from the Standard - thank you Smile (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



Back to top
Christopher Benson-Manica
Guest





PostPosted: Thu Feb 26, 2004 9:55 pm    Post subject: Re: using declaration question Reply with quote

Jonathan Turkanis <technews (AT) kangaroologic (DOT) com> spoke thus:

Quote:
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 ;)

Quote:
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.

Back to top
Ralf Schneewei?
Guest





PostPosted: Thu Feb 26, 2004 11:39 pm    Post subject: Re: using declaration question Reply with quote

Christopher Benson-Manica <ataru (AT) nospam (DOT) cyberspace.org> wrote

Quote:
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

Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.