Multiple inheritance doubt

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • pradeep

    #1

    Multiple inheritance doubt

    Hello friends:

    In the following setup,

    class A {
    ...
    };

    class B {
    ...
    };

    class C : public A, public B {
    ...
    }

    void main()
    {
    A* x = new C;
    delete (x);
    }

    Does the B part of x get deleted properly?

    Thanks.
  • dj3vande@csclub.uwaterloo.ca.invalid

    #2
    Re: Multiple inheritance doubt

    In article <fug8vu$2d2$1@a ioe.org>, pradeep <nospam@nospam. comwrote:
    >class A {
    This is not C...
    >void main()
    ....and this is not C++ (even more so than it is not C).

    Decide which language you're using, use it properly, and ask questions
    about it in the right place.


    dave

    --
    Dave Vandervies dj3vande at eskimo dot com
    Presumably you were trying to write an invalid program. You succeeded on
    several counts. I merely identified the first problem.
    --Richard Heathfield in comp.lang.c

    Comment

    • Antoninus Twink

      #3
      Re: Multiple inheritance doubt

      On 20 Apr 2008 at 20:27, pradeep wrote:
      class C : public A, public B {
      ...
      }
      >
      void main()
      {
      A* x = new C;
      delete (x);
      }
      >
      Does the B part of x get deleted properly?
      Yes, provided A has a virtual destructor.

      Comment

      • Andrey Tarasevich

        #4
        Re: Multiple inheritance doubt

        pradeep wrote:
        ...
        Please, direct your C++-related questions to a C++ newsgroup. This is a C
        newsgroup. C language has no classes, inheritance, etc.

        --
        Best regards,
        Andrey Tarasevich

        Comment

        • pradeep

          #5
          Re: Multiple inheritance doubt

          OK thanks for ur answer, can you explain more what's happening?

          To Audrey Tasarevich, I'm writing in C/C++ so I think this group is a
          good one for my question.

          Thanks.


          Antoninus Twink wrote:
          On 20 Apr 2008 at 20:27, pradeep wrote:
          >
          >>class C : public A, public B {
          > ...
          >>}
          >>
          >>void main()
          >>{
          > A* x = new C;
          > delete (x);
          >>}
          >>
          >>Does the B part of x get deleted properly?
          >
          >
          Yes, provided A has a virtual destructor.
          >

          Comment

          • Ian Collins

            #6
            Re: Multiple inheritance doubt

            pradeep wrote:

            [please don't top-post]
            >
            Antoninus Twink wrote:
            >>
            >Yes, provided A has a virtual destructor.
            >>
            OK thanks for ur answer, can you explain more what's happening?
            >
            To Audrey Tasarevich, I'm writing in C/C++ so I think this group is a
            good one for my question.
            >
            No, you are writing C++, that group is down the hall. You might get one
            person's opinion here, you will get many there.

            --
            Ian Collins.

            Comment

            • Keith Thompson

              #7
              Re: Multiple inheritance doubt

              pradeep <nospam@nospam. comwrites:
              OK thanks for ur answer, can you explain more what's happening?
              >
              To Audrey Tasarevich, I'm writing in C/C++ so I think this group is a
              good one for my question.
              >
              Thanks.
              No, C and C++ are two different languages. C does not have multiple
              inheritance. C++ has its own set of newsgroups, including
              comp.lang.c++, where questions about multiple inheritance would be
              appropriate.

              "Antoninus Twink" wants you to think that comp.lang.c is an appropriate
              place for questions about C++.

              "Antoninus Twink" is lying to you.

              --
              Keith Thompson (The_Other_Keit h) <kst-u@mib.org>
              Nokia
              "We must do something. This is something. Therefore, we must do this."
              -- Antony Jay and Jonathan Lynn, "Yes Minister"

              Comment

              • CBFalconer

                #8
                Re: Multiple inheritance doubt

                pradeep wrote:
                >
                OK thanks for ur answer, can you explain more what's happening?
                >
                To Audrey Tasarevich, I'm writing in C/C++ so I think this group
                is a good one for my question.
                There is no such language, nor is there any user 'ur'. There are C
                and C++ languages, which are different. You are apparently using
                C++, and your questions should go to comp.lang.c++. FUPs set.

                --
                [mail]: Chuck F (cbfalconer at maineline dot net)
                [page]: <http://cbfalconer.home .att.net>
                Try the download section.


                ** Posted from http://www.teranews.com **

                Comment

                Working...