C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Call virtual method from base's destructor

From: Thiago Macieira <thiago_at_[hidden]>
Date: Wed, 29 May 2024 16:32:01 -0300
On Wednesday 29 May 2024 07:38:14 GMT-3 Frederick Virchanza Gotham via Std-
Proposals wrote:
> now I had to close the COM port upon destruction. I
> wanted to put the 'Close' operation inside the base class rather than
> have to put it in all the derived classes (e.g. RS232_Microcontroller,
> RS232_Win32, RS232_Boost, etc.

In the spirit of polymorphism, what you needed was a ClosingRS232 class that
is the base of all those above and does call Close().

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
  Principal Engineer - Intel DCAI Fleet Engineering and Quality

Received on 2024-05-29 19:32:07