• Post Reply Bookmark Topic Watch Topic
  • New Topic

Interface and inheritance  RSS feed

 
Karen Boxby
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The code below is a question from Dan Chisholm's website of comprehensive tests. The code originally demonstrated a compilation error, but I modified it so it would compile. I wanted to verify that it returned a "A", but it returned a "B" instead. I don't understand why that is -- could someone explain it to me?
 
Sresh Rangi
Ranch Hand
Posts: 54
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because they have the same name, the s1 variable in A is "hidden" by the s1 variable in B. The variable in A still exists, and can be accessed by:

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!