CATEGORII DOCUMENTE |
Asp | Autocad | C | Dot net | Excel | Fox pro | Html | Java |
Linux | Mathcad | Photoshop | Php | Sql | Visual studio | Windows | Xml |
Only C++ programmers might be surprised by name hiding, since it works differently in that language. If a Java base class has a method name that's overloaded several times, redefining that method name in the derived class will not hide any of the base-class versions. Thus overloading works regardless of whether the method was defined at this level or in a base class:
//: Hide.java
// Overloading a base-class method name
// in a derived class does not hide the
// base-class versions
class Homer
float doh(float f)
class Milhouse
class Bart extends Homer {
void doh(Milhouse m)
class Hide
As you'll see in the next chapter, it's far more common to override methods of the same name using exactly the same signature and return type as in the base class. It can be confusing otherwise (which is why C++ disallows it, to prevent you from making what is probably a mistake).
Politica de confidentialitate | Termeni si conditii de utilizare |
Vizualizari: 814
Importanta:
Termeni si conditii de utilizare | Contact
© SCRIGROUP 2024 . All rights reserved