An understanding of abstract methods.

When we first learn about abstract classes, we often have such doubts: since we can write our own methods in subclasses, why should we write abstract methods in abstract classes? Isn't it redundant? In fact, taking the class of printers as an example, the subclasses include black and white printers, color printers, laser printers, etc. Before we understand their characteristics, we only know that they are printers, and the most important function is printing. If you don't have this function, it will lose its meaning, so we have to write a printed abstract method in the abstract class to force them to have this function.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324683664&siteId=291194637