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. hlp its urgent

hlp its urgent

Scheduled Pinned Locked Moved C / C++ / MFC
questionoopperformance
22 Posts 8 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.
  • D Offline
    D Offline
    DX Roster
    wrote on last edited by
    #1

    Question: In Polymorphism we give same name to function (function overloading).. so each function takes same memory or different?? If Yes than How and If no then why?? Please reply me as earlier as possible

    C C _ K 4 Replies Last reply
    0
    • D DX Roster

      Question: In Polymorphism we give same name to function (function overloading).. so each function takes same memory or different?? If Yes than How and If no then why?? Please reply me as earlier as possible

      C Offline
      C Offline
      Cedric Moonen
      wrote on last edited by
      #2

      First think, when posting use a relevant title. "hlp its urgent" is relevant at all: we know that you want help (why would you ask a question otherwise ?). Furthermore urgent requests are considered rude. Why would your question be more urgent than somebody else's question ? Please, next time before posting, read the posting guidelines ("How to ask a question") at the top of this message board. Now for your question, I suggest you take a look at this[^]. You can also google for "virtual table" for more information.

      Cédric Moonen Software developer
      Charting control [v3.0] OpenGL game tutorial in C++

      1 Reply Last reply
      0
      • D DX Roster

        Question: In Polymorphism we give same name to function (function overloading).. so each function takes same memory or different?? If Yes than How and If no then why?? Please reply me as earlier as possible

        C Offline
        C Offline
        CPallini
        wrote on last edited by
        #3

        When you overload a function, basically you're giving the same name to two different functions (the compiler produces two functions with two different names in the object file) hence two different portions of code memory are, of course, used. :)

        DX Roster wrote:

        Please reply me as earlier as possible

        :-D

        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]

        P 1 Reply Last reply
        0
        • D DX Roster

          Question: In Polymorphism we give same name to function (function overloading).. so each function takes same memory or different?? If Yes than How and If no then why?? Please reply me as earlier as possible

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

          It is possible by name mangling. The compiler actually generates different names for the functions. Read how Visual C++ compiler does this - Microsoft Visual C++ Name Mangling[^]

          «_Superman_» I love work. It gives me something to do between weekends.
          Microsoft MVP (Visual C++)

          C 1 Reply Last reply
          0
          • _ _Superman_

            It is possible by name mangling. The compiler actually generates different names for the functions. Read how Visual C++ compiler does this - Microsoft Visual C++ Name Mangling[^]

            «_Superman_» I love work. It gives me something to do between weekends.
            Microsoft MVP (Visual C++)

            C Offline
            C Offline
            Cedric Moonen
            wrote on last edited by
            #5

            Mmmh, I'm confused now. I don't know if he was talking about function overloading or function overriding. He used the word overloading but he also talked about polymorphism (which has nothing to do with overloading but with overriding).

            Cédric Moonen Software developer
            Charting control [v3.0] OpenGL game tutorial in C++

            R C 2 Replies Last reply
            0
            • C Cedric Moonen

              Mmmh, I'm confused now. I don't know if he was talking about function overloading or function overriding. He used the word overloading but he also talked about polymorphism (which has nothing to do with overloading but with overriding).

              Cédric Moonen Software developer
              Charting control [v3.0] OpenGL game tutorial in C++

              R Offline
              R Offline
              Rajesh R Subramanian
              wrote on last edited by
              #6

              Cedric Moonen wrote:

              he also talked about polymorphism (which has nothing to do with overloading but with overriding).

              Overloading is also a type of polymorphism - compile time polymorphism. :)

              “Follow your bliss.” – Joseph Campbell

              _ 1 Reply Last reply
              0
              • R Rajesh R Subramanian

                Cedric Moonen wrote:

                he also talked about polymorphism (which has nothing to do with overloading but with overriding).

                Overloading is also a type of polymorphism - compile time polymorphism. :)

                “Follow your bliss.” – Joseph Campbell

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

                There you have it. :) Let's leave it to him to choose what he wants.

                «_Superman_» I love work. It gives me something to do between weekends.
                Microsoft MVP (Visual C++)

                D 1 Reply Last reply
                0
                • C Cedric Moonen

                  Mmmh, I'm confused now. I don't know if he was talking about function overloading or function overriding. He used the word overloading but he also talked about polymorphism (which has nothing to do with overloading but with overriding).

                  Cédric Moonen Software developer
                  Charting control [v3.0] OpenGL game tutorial in C++

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

                  As strange may appear (at least it appears strange to me), overloading is considered polymorphism (after all, you are issuing the same request on objects of different nature and the behaviour may be different on such different types). :)

                  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]

                  C 1 Reply Last reply
                  0
                  • C CPallini

                    As strange may appear (at least it appears strange to me), overloading is considered polymorphism (after all, you are issuing the same request on objects of different nature and the behaviour may be different on such different types). :)

                    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]

                    C Offline
                    C Offline
                    Cedric Moonen
                    wrote on last edited by
                    #9

                    Yeah, that's what Rajesh also said but I honnestly don't think that's what the OP meant by polymorphism :)

                    Cédric Moonen Software developer
                    Charting control [v3.0] OpenGL game tutorial in C++

                    C 1 Reply Last reply
                    0
                    • C Cedric Moonen

                      Yeah, that's what Rajesh also said but I honnestly don't think that's what the OP meant by polymorphism :)

                      Cédric Moonen Software developer
                      Charting control [v3.0] OpenGL game tutorial in C++

                      C Offline
                      C Offline
                      CPallini
                      wrote on last edited by
                      #10

                      The OP request was fully polymorphic: it generated completely different reactions from the different subjects... :laugh:

                      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]

                      1 Reply Last reply
                      0
                      • D DX Roster

                        Question: In Polymorphism we give same name to function (function overloading).. so each function takes same memory or different?? If Yes than How and If no then why?? Please reply me as earlier as possible

                        K Offline
                        K Offline
                        KingsGambit
                        wrote on last edited by
                        #11

                        Static/compile time polymorphism has another form also, which is extensively used by ATL classes. http://en.wikipedia.org/wiki/Curiously_recurring_template_pattern[^]

                        C 1 Reply Last reply
                        0
                        • K KingsGambit

                          Static/compile time polymorphism has another form also, which is extensively used by ATL classes. http://en.wikipedia.org/wiki/Curiously_recurring_template_pattern[^]

                          C Offline
                          C Offline
                          CPallini
                          wrote on last edited by
                          #12

                          Yes, that's one of the reasons you never need a code obfuscator for ATL sources...

                          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]

                          K 1 Reply Last reply
                          0
                          • C CPallini

                            Yes, that's one of the reasons you never need a code obfuscator for ATL sources...

                            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]

                            K Offline
                            K Offline
                            KingsGambit
                            wrote on last edited by
                            #13

                            Nice joke :)

                            T 1 Reply Last reply
                            0
                            • _ _Superman_

                              There you have it. :) Let's leave it to him to choose what he wants.

                              «_Superman_» I love work. It gives me something to do between weekends.
                              Microsoft MVP (Visual C++)

                              D Offline
                              D Offline
                              DX Roster
                              wrote on last edited by
                              #14

                              sir i want to know that if i write two function with same name(Polymorphism function overloading) then both function will take same memory or different.. if both will take same memory then how???

                              _ C 2 Replies Last reply
                              0
                              • D DX Roster

                                sir i want to know that if i write two function with same name(Polymorphism function overloading) then both function will take same memory or different.. if both will take same memory then how???

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

                                They will actually become 2 different functions with different names. The change in names is done by the compiler and this is called name mangling.

                                «_Superman_» I love work. It gives me something to do between weekends.
                                Microsoft MVP (Visual C++)

                                D C 2 Replies Last reply
                                0
                                • _ _Superman_

                                  They will actually become 2 different functions with different names. The change in names is done by the compiler and this is called name mangling.

                                  «_Superman_» I love work. It gives me something to do between weekends.
                                  Microsoft MVP (Visual C++)

                                  D Offline
                                  D Offline
                                  DX Roster
                                  wrote on last edited by
                                  #16

                                  sir so both function will take different memory.... is it correct then how??? plz

                                  C 1 Reply Last reply
                                  0
                                  • D DX Roster

                                    sir i want to know that if i write two function with same name(Polymorphism function overloading) then both function will take same memory or different.. if both will take same memory then how???

                                    C Offline
                                    C Offline
                                    Cedric Moonen
                                    wrote on last edited by
                                    #17

                                    DX Roster wrote:

                                    Polymorphism function overloading

                                    Did you follow our discution ? If yes, do you understand the difference between function overloading (two functions with the same name but different arguments) and function overriding (a function which is redefined in a child class) ? So please, indicates which is the exact case you are interested in, because these are two completely different cases.

                                    Cédric Moonen Software developer
                                    Charting control [v3.0] OpenGL game tutorial in C++

                                    1 Reply Last reply
                                    0
                                    • _ _Superman_

                                      They will actually become 2 different functions with different names. The change in names is done by the compiler and this is called name mangling.

                                      «_Superman_» I love work. It gives me something to do between weekends.
                                      Microsoft MVP (Visual C++)

                                      C Offline
                                      C Offline
                                      Cedric Moonen
                                      wrote on last edited by
                                      #18

                                      In case of overloading yes. It still isn't clear (at least for me) if he really meant overloading (he didn't answer the question, just put the words in a different order ;P ).

                                      Cédric Moonen Software developer
                                      Charting control [v3.0] OpenGL game tutorial in C++

                                      1 Reply Last reply
                                      0
                                      • D DX Roster

                                        sir so both function will take different memory.... is it correct then how??? plz

                                        C Offline
                                        C Offline
                                        Cedric Moonen
                                        wrote on last edited by
                                        #19

                                        Anyway, if you meant overloading or overriding, both functions will start at different memory addresses (two different functions cannot start at the same memory address, it doesn't make sense).

                                        Cédric Moonen Software developer
                                        Charting control [v3.0] OpenGL game tutorial in C++

                                        1 Reply Last reply
                                        0
                                        • K KingsGambit

                                          Nice joke :)

                                          T Offline
                                          T Offline
                                          Tim Craig
                                          wrote on last edited by
                                          #20

                                          It was? :~ :laugh:

                                          You measure democracy by the freedom it gives its dissidents, not the freedom it gives its assimilated conformists.

                                          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