DET IT

zhaozj2021-02-08  253

Sorry, borrow a place. ;)

We generally use the following ways in class overload:

Class base {void echo () {printf ("echo from base");}};

Class Middle: Public Base {}

Class Child: public middle {}

It can be clearly seen that the overload process is base-> middle-> child. Such a structure can use the default overload mode.

Void main () {Child C; c.echo (); // correct.

But at some point, we need to separate several subclasses from the base class, and then multiple inheritances by subclasses, this time the method will be wrong.

such as:

Class base {void echo () {Printf ("Echo from Base class overload us generally use the following way:

Class base {void echo () {printf ("echo from base");}};

Class Middle: Public Base {}

Class Child: public middle {}

It can be clearly seen that the overload process is base-> middle-> child. Such a structure can use the default overload mode.

Void main () {Child C; c.echo (); // correct.

But at some point, we need to separate several subclasses from the base class, and then multiple inheritances by subclasses, this time the method will be wrong.

such as:

Class base {void echo () {printf ("echo from base

转载请注明原文地址:https://www.9cbs.com/read-1767.html

New Post(0)