Structure

xiaoxiao2021-04-08  433

What if you want to define an abstract base class? Then define a pure virtual function. What if it is missing such a function? Oh, don't worry, there is ready-made. It is a destructor. Consider the following code.

Class

Base

{

public

:

Virtual

~

Base

() = 0;

}

Base

:: ~

Base

() {

PRINTF

(

"Base :: ~ base () ./ n"

}

Class

Derive

:

public

Base

{

}

I have never tried this before, which makes me feel very fresh. It turns out that there is still a problem with the understanding of the pure virtual function, and it is a progress in recent days.

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

New Post(0)