hlp its urgent
-
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
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++ -
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
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] -
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
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++) -
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++)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++ -
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++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
-
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
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++) -
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++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] -
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]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++ -
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++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] -
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
Static/compile time polymorphism has another form also, which is extensively used by ATL classes. http://en.wikipedia.org/wiki/Curiously_recurring_template_pattern[^]
-
Static/compile time polymorphism has another form also, which is extensively used by ATL classes. http://en.wikipedia.org/wiki/Curiously_recurring_template_pattern[^]
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] -
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]Nice joke :)
-
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++) -
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???
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++) -
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++) -
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???
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++ -
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++)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++ -
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++ -
Nice joke :)