Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Vtable for derived calss

Vtable for derived calss

Scheduled Pinned Locked Moved C / C++ / MFC
question
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Cpp_Com
    wrote on last edited by
    #1

    Hi All suppose i ve a class class BAse {public: virtual void f(); }; class derive: public Base { public: void myFunc(); }; in this case vtable ll be created for derive class or not? Thank you all in advance.

    CPalliniC A S 3 Replies Last reply
    0
    • C Cpp_Com

      Hi All suppose i ve a class class BAse {public: virtual void f(); }; class derive: public Base { public: void myFunc(); }; in this case vtable ll be created for derive class or not? Thank you all in advance.

      CPalliniC Online
      CPalliniC Online
      CPallini
      wrote on last edited by
      #2

      kanungosudhansu wrote:

      in this case vtable ll be created for derive class or not?

      In this case you get compiler errors... :rolleyes: Rearranging to make it compile

      #include <stdio.h>
      class Base
      {
      public:
      virtual void f(){printf("hi\n");};
      };

      class Derived: public Base
      {
      public:
      void myFunc(){printf("people\n");};
      };

      void main()
      {
      Derived d;
      d.f();
      }

      You may verify that the virtual table is, of course, created. :)

      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
      This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
      [My articles]

      In testa che avete, signor di Ceprano?

      1 Reply Last reply
      0
      • C Cpp_Com

        Hi All suppose i ve a class class BAse {public: virtual void f(); }; class derive: public Base { public: void myFunc(); }; in this case vtable ll be created for derive class or not? Thank you all in advance.

        A Offline
        A Offline
        Anish C V
        wrote on last edited by
        #3

        Of course it will create, if one parent class has atleast one virtual function. Anish C.V

        http://www.iedetech.com

        1 Reply Last reply
        0
        • C Cpp_Com

          Hi All suppose i ve a class class BAse {public: virtual void f(); }; class derive: public Base { public: void myFunc(); }; in this case vtable ll be created for derive class or not? Thank you all in advance.

          S Offline
          S Offline
          Stuart Dootson
          wrote on last edited by
          #4

          It'll have a vtable, but it may be the same vtable as the base class, as no virtual methods are overridden in the derived class.

          Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups