cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
General C++ Programming
Why pure virtual destructor should have
Why pure virtual destructor should have body.
Feb 6, 2014 at 8:58pm UTC
murali2425
(11)
Why we should provide body to pure virtual destructor?
Thanks
Feb 6, 2014 at 9:24pm UTC
ResidentBiscuit
(4459)
Because when anything deriving this class gets destructed, the base class destructor will be called also. If there's no body, then you've entered undefined behavior.
Feb 6, 2014 at 10:06pm UTC
ne555
(10692)
If there is no body it would not build properly.
You can do
1
2
3
4
class
foo{
public
:
virtual
~foo() =
default
; };
Topic archived. No new replies allowed.