Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Say that you have a method in a base class that you need to change. For example, say you have a method named print in the base class Class1 that prints “This is class 1.” Clearly, in the derived class, Class2, the message should say, “This is class 2.”
You can override the base class print method just by redefining it in the derived class. When you override a method in a derived class, the overriding method must have the same prototype (same return type and arguments) as the method you’re overriding.