{"id":4402,"date":"2014-03-30T10:35:25","date_gmt":"2014-03-30T10:35:25","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/problem-about-method-hiding-collection-of-common-programming-errors\/"},"modified":"2014-03-30T10:35:25","modified_gmt":"2014-03-30T10:35:25","slug":"problem-about-method-hiding-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/problem-about-method-hiding-collection-of-common-programming-errors\/","title":{"rendered":"problem about method-hiding-Collection of common programming errors"},"content":{"rendered":"<ul>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/4a57f523157ebdf6e5a9662d2e8754b9?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nmax<br \/>\noop class inheritance override method-hiding<br \/>\nI&#8217;m trying to understand whether the answer to the following question is the same in all major OOP languages; and if not, then how do those languages differ.Suppose I have class A that defines methods act and jump; method act calls method jump. A&#8217;s subclass B overrides method jump (i.e., the appropriate syntax is used to ensure that whenever jump is called, the implementation in class B is used).I have object b of class B. I want it to behave exactly as if it was of class A. In other words, I wa<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/0159784729683001695a04568a4cc236?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nGroo<br \/>\nc# methods method-hiding<br \/>\nPer MSDN, the &#8220;new&#8221; keyword when used for method hiding only suppresses a warning. http:\/\/msdn.microsoft.com\/en-us\/library\/435f1dw2.aspxDo I really need this &#8220;new&#8221; keyword to perform method hiding? If I have a child class that has the same method name but doesn&#8217;t explicitly state that it is overriding, isn&#8217;t that the same thing essentially, I just get a warning? Please tell me if my understanding is correct. Thanks<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/b8e8bce142e9137b585b3aa712128ca5?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nfearofawhackplanet<br \/>\nc# unit-testing inheritance method-hiding method-overriding<br \/>\npublic class Foo {public string Test(){return GetName();}public string GetName(){return &#8220;Foo&#8221;;} }public class Bar : Foo {public new string GetName(){return &#8220;Bar&#8221;;} }new Foo().Test(); \/\/ Foonew Bar().Test(); \/\/ also FooI was trying to create a &#8220;wrapper&#8221; for Foo so that I could unit test the behaviour of Test() when GetName() produces unexpected values. I cannot directly influence the behaviour of GetName() in Foo as it is dependent on ASP.NET pipeline events.I was hopingnew Bar().Test();would ret<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/6c13bf9cfcead87d332701ff860fbc84?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nS.L. Barth<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/0159784729683001695a04568a4cc236?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nGroo<br \/>\nc# inheritance interface method-hiding<br \/>\nI am getting the following Compiler Warning:&#8217;Resources.Foo.GetType()&#8217; hides inherited member &#8216;object.GetType()&#8217;. Use the new keyword if hiding was intended. Resources.NET\\Resources\\Class1.cs 123 20 Resourcesfor this (very simplified) code:public interface IFoo {int GetType();string GetDisplayName(); }public class Foo : IFoo {public int GetType() { return 3; } *** Warning: points to here (line 123)***public string GetDisplayName() { return &#8220;Foo&#8221;; } }Note, what I don&#8217;t get is why the GetDis<\/li>\n<\/ul>\n<p>Web site is in building<\/p>\n","protected":false},"excerpt":{"rendered":"<p>max oop class inheritance override method-hiding I&#8217;m trying to understand whether the answer to the following question is the same in all major OOP languages; and if not, then how do those languages differ.Suppose I have class A that defines methods act and jump; method act calls method jump. A&#8217;s subclass B overrides method jump [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-4402","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4402","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=4402"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4402\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=4402"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=4402"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=4402"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}