|
Lets say I have some inheritance going on; I have a "Base" class and a "Derived" class. SomeMethod exists in both classes, but takes different parameters. I want to call the derived SomeMethod for obj. I'm trying to implement something that uses this and can't get it to work : ( "No overload for method SomeMethod takes 2 arguments". It looks like the method in the derived class can't be seen at all.
(comments are locked)
|
|
Correct, it cannot be seen since obj is a Base. Just because you know it is a Derived does not allow you to call subclass methods. Binding is static, not dynamic. You must assert your knowledge with a downcast: If you do this a lot, I would suggest that obj be private Derived and that the public interface be a getter that returns it as a Base. Thank you! : 3
Aug 01 '11 at 09:23 PM
crump3ts
(comments are locked)
|
