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. Doubt in c++

Doubt in c++

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++
6 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.
  • J Offline
    J Offline
    Jackkrishjk
    wrote on last edited by
    #1

    what is the importance of virtual and pure virtual fuctions?

    L A D M 4 Replies Last reply
    0
    • J Jackkrishjk

      what is the importance of virtual and pure virtual fuctions?

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      See here[^].

      1 Reply Last reply
      0
      • J Jackkrishjk

        what is the importance of virtual and pure virtual fuctions?

        A Offline
        A Offline
        Alan Balkany
        wrote on last edited by
        #3

        They allow polymorphism, where derived classes can provide different behavior for the same function calls. For example, a Shape class can have a virtual getArea () method. Derived classes (like Circle, Square, etc...) will provide different implementations of getArea (), which use different formulas for the area calculation. Thus, you can call getArea () on a Shape object, regardless of which concrete derived class it represents, and you'll get the correct area.

        S 1 Reply Last reply
        0
        • A Alan Balkany

          They allow polymorphism, where derived classes can provide different behavior for the same function calls. For example, a Shape class can have a virtual getArea () method. Derived classes (like Circle, Square, etc...) will provide different implementations of getArea (), which use different formulas for the area calculation. Thus, you can call getArea () on a Shape object, regardless of which concrete derived class it represents, and you'll get the correct area.

          S Offline
          S Offline
          SajeeshCheviry
          wrote on last edited by
          #4

          Yes. you are right.Using these functionality in c++ we can make good code design also.

          1 Reply Last reply
          0
          • J Jackkrishjk

            what is the importance of virtual and pure virtual fuctions?

            D Offline
            D Offline
            David Crow
            wrote on last edited by
            #5

            Try here.

            "One man's wage rise is another man's price increase." - Harold Wilson

            "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

            "Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous

            1 Reply Last reply
            0
            • J Jackkrishjk

              what is the importance of virtual and pure virtual fuctions?

              M Offline
              M Offline
              Maximilien
              wrote on last edited by
              #6

              Jackkrishjk wrote:

              what is the importance of virtual and pure virtual fuctions?

              VERY important. ;P

              Nihil obstat

              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