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. What do virtual inline function mean?

What do virtual inline function mean?

Scheduled Pinned Locked Moved C / C++ / MFC
question
5 Posts 5 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.
  • V Offline
    V Offline
    vikas amin
    wrote on last edited by
    #1

    If declare a virtual function as inline what is the effect on the code. Vikas Amin Embin Technology Bombay

    T 1 Reply Last reply
    0
    • V vikas amin

      If declare a virtual function as inline what is the effect on the code. Vikas Amin Embin Technology Bombay

      T Offline
      T Offline
      toxcct
      wrote on last edited by
      #2

      it will try to inline the function if it provides an implementation of the function that is actually called...


      TOXCCT >>> GEII power
      [toxcct][VisualCalc 2.20][VCalc 3.0 soon...]

      T 1 Reply Last reply
      0
      • T toxcct

        it will try to inline the function if it provides an implementation of the function that is actually called...


        TOXCCT >>> GEII power
        [toxcct][VisualCalc 2.20][VCalc 3.0 soon...]

        T Offline
        T Offline
        Taka Muraoka
        wrote on last edited by
        #3

        Actually, it won't. "virtual inline" makes no sense and the inline specifier will be ignored. Virtual functions let an object decide at runtime which particular implementation of a method should be invoked. If you have a pointer to the base object and call a virtual method, there is no way to know at compile time what type of object will be present at the actual time of the call. Hence, the compiler won't be able to figure out which implementation of the function to compile inline.


        The two most common elements in the universe are Hydrogen and stupidity. - Harlan Ellison Awasu 2.2 [^]: A free RSS/Atom feed reader with support for Code Project.

        P N 2 Replies Last reply
        0
        • T Taka Muraoka

          Actually, it won't. "virtual inline" makes no sense and the inline specifier will be ignored. Virtual functions let an object decide at runtime which particular implementation of a method should be invoked. If you have a pointer to the base object and call a virtual method, there is no way to know at compile time what type of object will be present at the actual time of the call. Hence, the compiler won't be able to figure out which implementation of the function to compile inline.


          The two most common elements in the universe are Hydrogen and stupidity. - Harlan Ellison Awasu 2.2 [^]: A free RSS/Atom feed reader with support for Code Project.

          P Offline
          P Offline
          Prakash Nadar
          wrote on last edited by
          #4

          exactly!!


          -Prakash

          1 Reply Last reply
          0
          • T Taka Muraoka

            Actually, it won't. "virtual inline" makes no sense and the inline specifier will be ignored. Virtual functions let an object decide at runtime which particular implementation of a method should be invoked. If you have a pointer to the base object and call a virtual method, there is no way to know at compile time what type of object will be present at the actual time of the call. Hence, the compiler won't be able to figure out which implementation of the function to compile inline.


            The two most common elements in the universe are Hydrogen and stupidity. - Harlan Ellison Awasu 2.2 [^]: A free RSS/Atom feed reader with support for Code Project.

            N Offline
            N Offline
            Nemanja Trifunovic
            wrote on last edited by
            #5

            Taka Muraoka wrote:

            Virtual functions let an object decide at runtime which particular implementation of a method should be invoked. If you have a pointer to the base object and call a virtual method, there is no way to know at compile time what type of object will be present at the actual time of the call. Hence, the compiler won't be able to figure out which implementation of the function to compile inline

            This is of course, correct. However, if you use an object of the class in a non-polymorphic manner (say, create it on the stack), the compiler can figure out which object is used and inline the function. Therefore, "virtual inline" actually makes sense, and will not be ignored ;)


            My programming blahblahblah blog. If you ever find anything useful here, please let me know to remove it.

            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