Home > Net > The great spirit on the c #, head hurts
The great spirit on the c #, head hurts
Time:10-03
Great god explain example 9.13, that's don't understand, for no reason
CodePudding user response:
Explanation is no use, best to play a practical procedure, himself running to see A look not to understand, but don't look at this and see
CodePudding user response:
To be honest I don't know what is the purpose of this book such a problem? Subclass inherits parent class performs the inside of the parent class method, but also don't like ah, otherwise it is not necessary to do so complicated! Tell the reader program can also write like this? Not necessary, readability is not so high!
CodePudding user response:
Did this topic out of trouble, the explanation is in place,
But the only problem is that the sample program, don't know which nerve is wrong, the author Why do you want to put the Program as a base class of these classes,
CodePudding user response:
Give you a simple example
CodePudding user response:
This is called polymorphism, in the method the
Part 2 interface form
Part 1 is a class form
Override, the new method
CodePudding user response:
According to specific application scenarios under entangled with abstract classes, virtual method and abstract methods can be rewritten or cover, this even polymorphism,
CodePudding user response:
Polymorphism is: Animals is a base class, have to eat this way, But eating chicken, dog eating specific is not the same (chickens without teeth can only swallow, dogs can have teeth chew) If there are both chicken and dog, always can't eat, called again to call the dog In a word: eat So chickens, dogs are just open to eat, you don't need to care about dogs or chicken, also don't need to care about how to eat, even if again many animals don't have to worry about,