using declaration question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Christopher Benson-Manica

    using declaration question

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

    using MyClass::~MyCla ss;

    ?

    --
    Christopher Benson-Manica | I *should* know what I'm talking about - if I
    ataru(at)cybers pace.org | don't, I need to know. Flames welcome.
  • Jonathan Turkanis

    #2
    Re: using declaration question


    "Christophe r Benson-Manica" <ataru@nospam.c yberspace.org> wrote in
    message news:c1lihi$504 $1@chessie.cirr .com...[color=blue]
    > Why can't I use a class destructor in a using declaration:
    >
    > using MyClass::~MyCla ss;
    >[/color]

    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


    Comment

    • Pete Becker

      #3
      Re: using declaration question

      Christopher Benson-Manica wrote:[color=blue]
      >
      > Why can't I use a class destructor in a using declaration:
      >
      > using MyClass::~MyCla ss;
      >[/color]

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

      --

      Pete Becker
      Dinkumware, Ltd. (http://www.dinkumware.com)

      Comment

      • Mike Wahler

        #4
        Re: using declaration question


        "Christophe r Benson-Manica" <ataru@nospam.c yberspace.org> wrote in message
        news:c1lihi$504 $1@chessie.cirr .com...[color=blue]
        > Why can't I use a class destructor in a using declaration:
        >
        > using MyClass::~MyCla ss;[/color]

        =============== =============== =============== =============== ========
        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



        Comment

        • Mike Wahler

          #5
          Re: using declaration question


          "Jonathan Turkanis" <technews@kanga roologic.com> wrote in message
          news:c1lk2v$1jg 271$1@ID-216073.news.uni-berlin.de...[color=blue]
          >
          > "Christophe r Benson-Manica" <ataru@nospam.c yberspace.org> wrote in
          > message news:c1lihi$504 $1@chessie.cirr .com...[color=green]
          > > Why can't I use a class destructor in a using declaration:
          > >
          > > using MyClass::~MyCla ss;
          > >[/color]
          >
          > Interesting question! It seems to be allowed by the grammar; it may be
          > illegal for some other reason, however.[/color]

          Yes, see 7.3.3.4
          [color=blue]
          >
          > VC7.1 is the only compiler I've tried which accepts it.[/color]

          Baaad Microsoft! :-)

          -Mike


          Comment

          • Jonathan Turkanis

            #6
            Re: using declaration question


            "Mike Wahler" <mkwahler@mkwah ler.net> wrote in message
            news:UCs%b.9463 $yZ1.1169@newsr ead2.news.pas.e arthlink.net...[color=blue]
            >
            > "Jonathan Turkanis" <technews@kanga roologic.com> wrote in message
            > news:c1lk2v$1jg 271$1@ID-216073.news.uni-berlin.de...[color=green]
            > >
            > > "Christophe r Benson-Manica" <ataru@nospam.c yberspace.org> wrote in
            > > message news:c1lihi$504 $1@chessie.cirr .com...[color=darkred]
            > > > Why can't I use a class destructor in a using declaration:
            > > >
            > > > using MyClass::~MyCla ss;
            > > >[/color]
            > >
            > > Interesting question! It seems to be allowed by the grammar; it[/color][/color]
            may be[color=blue][color=green]
            > > illegal for some other reason, however.[/color]
            >
            > Yes, see 7.3.3.4
            >[/color]

            That'll teach me to skip over notes!

            Jonathan


            Comment

            • Christopher Benson-Manica

              #7
              Re: using declaration question

              Mike Wahler <mkwahler@mkwah ler.net> spoke thus:
              [color=blue]
              > 7.3.3 The using declaration[/color]
              [color=blue]
              > snip lovely quote from Standard[/color]

              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)cybers pace.org | don't, I need to know. Flames welcome.

              Comment

              • Mike Wahler

                #8
                Re: using declaration question

                "Christophe r Benson-Manica" <ataru@nospam.c yberspace.org> wrote in message
                news:c1llrj$622 $1@chessie.cirr .com...[color=blue]
                > Mike Wahler <mkwahler@mkwah ler.net> spoke thus:
                >[color=green]
                > > 7.3.3 The using declaration[/color]
                >[color=green]
                > > snip lovely quote from Standard[/color]
                >
                > Ah, a quote from the Standard - thank you :) (even though it has now
                > obliterated all my hopes and dreams...)[/color]

                Please don't shoot the messenger. :-)
                [color=blue]
                > 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*[/color]

                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


                Comment

                • Jonathan Turkanis

                  #9
                  Re: using declaration question


                  "Christophe r Benson-Manica" <ataru@nospam.c yberspace.org> wrote in
                  message news:c1llrj$622 $1@chessie.cirr .com...[color=blue]
                  > Mike Wahler <mkwahler@mkwah ler.net> spoke thus:[/color]
                  [color=blue]
                  > Ah, a quote from the Standard - thank you :) (even though it has now
                  > obliterated all my hopes and dreams...) So here's my SUPER[/color]
                  question:[color=blue]
                  > How can I reconcile conflicting destructor declarations when[/color]
                  multiply[color=blue]
                  > inheriting, which I WOULD do with using; if that old wolf Stroustrup
                  > hadn't forbidden it...? *sigh*[/color]

                  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


                  Comment

                  • Christopher Benson-Manica

                    #10
                    Re: using declaration question

                    Jonathan Turkanis <technews@kanga roologic.com> spoke thus:
                    [color=blue]
                    > If you're not planning on calling the destructors explicitly, you
                    > don't need to reconcile them.[/color]

                    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 ;)
                    [color=blue]
                    > What are you trying to do?[/color]

                    Not go insane...

                    --
                    Christopher Benson-Manica | I *should* know what I'm talking about - if I
                    ataru(at)cybers pace.org | don't, I need to know. Flames welcome.

                    Comment

                    • Ralf Schneewei?

                      #11
                      Re: using declaration question

                      Christopher Benson-Manica <ataru@nospam.c yberspace.org> wrote in message news:<c1lihi$50 4$1@chessie.cir r.com>...[color=blue]
                      > Why can't I use a class destructor in a using declaration:
                      >
                      > using MyClass::~MyCla ss;
                      >
                      > ?[/color]

                      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

                      Seminare zur Softwareentwicklung

                      Comment

                      Working...