Results 1 to 3 of 3

Thread: Polymorphism interfaces in C++

  1. #1
    Join Date
    Mar 2008
    Location
    Houston, Texas, USA
    Posts
    277
    Thanks
    9
    Thanked 17 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Maemo/MeeGo

    Default Polymorphism interfaces in C++

    I've been using C++ for quite some time. But I never really asked how it knows to do this.

    void
    Foo::bar(BarInterface *bary) {
    delete *bary;
    }

    and say somewhere else you have like

    class FooBar : public BarInterface {
    };

    How does it know to call FooBar's constructor if it's cast into BarInterface first before deleting?
    Qt-4.7.3 | Gentoo ~amd64 | KDE-4.7
    Aki IRC Client for KDE4 | Qt Documentation

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Polymorphism interfaces in C++

    It uses a special pointer table called a vtable where it stores pointers to virtual methods (such as the destructor) associated with an object and the table travels with the object during its whole lifespan.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Mar 2008
    Location
    Houston, Texas, USA
    Posts
    277
    Thanks
    9
    Thanked 17 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Maemo/MeeGo

    Default Re: Polymorphism interfaces in C++

    lol. I forgot about that. xD. Thanks mate.
    Qt-4.7.3 | Gentoo ~amd64 | KDE-4.7
    Aki IRC Client for KDE4 | Qt Documentation

Similar Threads

  1. Object and multiple inheritance for interfaces
    By brcain in forum Qt Programming
    Replies: 8
    Last Post: 29th June 2021, 15:29
  2. Calling COM/DCOM interfaces from Qt App?
    By jaganpes in forum Qt Programming
    Replies: 3
    Last Post: 16th February 2008, 04:38
  3. Plugin interfaces, signals and slots
    By QPlace in forum Qt Programming
    Replies: 8
    Last Post: 9th August 2007, 21:19
  4. QVariant and Plugin interfaces
    By QPlace in forum Qt Programming
    Replies: 9
    Last Post: 6th August 2007, 00:04
  5. Plugin Interfaces
    By Paul Drummond in forum Qt Programming
    Replies: 1
    Last Post: 27th February 2006, 13:37

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.