I was just wondering why is that only member variable have static binding i.e they are decided by the object reference type while methods have the privelege of being decided at run time(object pointed to matters). So simplay why is that instance methods support polymorphism while member variables do not?
Interesting question. As to why, I guess it's just the language designer's choice. It kinda makes sense - you can override a method to change behavior, requiring late binding. But there's not much point in overriding a variable since it has no behavior. So maybe they figured if you defined a variable again, you must really want a distinct variable. Which assumes you did it on purpose, and I've done it by mistake many more times than on purpose!
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
What's wrong? Where are you going? Stop! Read this tiny ad: