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
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Virtual Function and Vtable

Virtual Function and Vtable

Scheduled Pinned Locked Moved C / C++ / MFC
help
8 Posts 6 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.
  • N Offline
    N Offline
    Neelesh K J Jain
    wrote on last edited by
    #1

    Hello Friends, I have virtual function in my class and I don't want the vtable to be created. Can anybody help regarding this one. Is there any method for the above problem or any keyword, which helps the programmer to avoid creating vtable for the class. Thanks in advance, Neelesh K J Jain.

    R N T C 4 Replies Last reply
    0
    • N Neelesh K J Jain

      Hello Friends, I have virtual function in my class and I don't want the vtable to be created. Can anybody help regarding this one. Is there any method for the above problem or any keyword, which helps the programmer to avoid creating vtable for the class. Thanks in advance, Neelesh K J Jain.

      R Offline
      R Offline
      Ryan Binns
      wrote on last edited by
      #2

      Neelesh K J Jain wrote: Is there any method for the above problem or any keyword, which helps the programmer to avoid creating vtable for the class. No. If you have a virtual function, there must be a vtable.

      Ryan

      "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"

      1 Reply Last reply
      0
      • N Neelesh K J Jain

        Hello Friends, I have virtual function in my class and I don't want the vtable to be created. Can anybody help regarding this one. Is there any method for the above problem or any keyword, which helps the programmer to avoid creating vtable for the class. Thanks in advance, Neelesh K J Jain.

        N Offline
        N Offline
        Nilesh K
        wrote on last edited by
        #3

        I doubt you can do anything of that, but incase if you were able to then your function would lose its advantage of being virtual and be as good as any other functions of your class. If that's ok then why not to remove the virtual keyword of the function. "Reading made Don Quixote a gentleman. Believing what he read made him mad" - Nilesh

        1 Reply Last reply
        0
        • N Neelesh K J Jain

          Hello Friends, I have virtual function in my class and I don't want the vtable to be created. Can anybody help regarding this one. Is there any method for the above problem or any keyword, which helps the programmer to avoid creating vtable for the class. Thanks in advance, Neelesh K J Jain.

          T Offline
          T Offline
          ThatsAlok
          wrote on last edited by
          #4

          Neelesh K J Jain wrote: I don't want the vtable to be created :confused: Why you don't want to create VTABLE?, Any specfic reason!

          "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

          cheers, Alok Gupta

          N 1 Reply Last reply
          0
          • T ThatsAlok

            Neelesh K J Jain wrote: I don't want the vtable to be created :confused: Why you don't want to create VTABLE?, Any specfic reason!

            "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

            cheers, Alok Gupta

            N Offline
            N Offline
            Neelesh K J Jain
            wrote on last edited by
            #5

            Actually I had been asked this question in one of my interview recently. My feeling is that if we could be able to avoid creating of Vtable, then I agree with the reply of Nilesh. No use of having virtual functions itself. So, I just wanted to know whether we can avoid creation of vtable, then how? Neelesh K J Jain.

            T 1 Reply Last reply
            0
            • N Neelesh K J Jain

              Actually I had been asked this question in one of my interview recently. My feeling is that if we could be able to avoid creating of Vtable, then I agree with the reply of Nilesh. No use of having virtual functions itself. So, I just wanted to know whether we can avoid creation of vtable, then how? Neelesh K J Jain.

              T Offline
              T Offline
              ThatsAlok
              wrote on last edited by
              #6

              Neelesh K J Jain wrote: I had been asked this question in one of my interview recently Hain, What's the result, Are you selected or Not!

              "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

              cheers, Alok Gupta

              _ 1 Reply Last reply
              0
              • T ThatsAlok

                Neelesh K J Jain wrote: I had been asked this question in one of my interview recently Hain, What's the result, Are you selected or Not!

                "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

                cheers, Alok Gupta

                _ Offline
                _ Offline
                _Superman_
                wrote on last edited by
                #7

                The interviewer probably wanted you to talk about the novtable attribute. This attribute is microsoft specific and is declared in front of the class name as __declspec(novtable). Giving this will not put the code in the constructor of the class to initialize the virtual table pointer of the class. But the virtual table will still be created. « Superman »

                1 Reply Last reply
                0
                • N Neelesh K J Jain

                  Hello Friends, I have virtual function in my class and I don't want the vtable to be created. Can anybody help regarding this one. Is there any method for the above problem or any keyword, which helps the programmer to avoid creating vtable for the class. Thanks in advance, Neelesh K J Jain.

                  C Offline
                  C Offline
                  cmk
                  wrote on last edited by
                  #8

                  __declspec(novtable) e.g. class __declspec(novtable) MyVBase { ... }; ...cmk Save the whales - collect the whole set

                  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