TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Pure virtual destructors in C++

10 pointsby kapilkaisareover 14 years ago

4 comments

joelburgetover 14 years ago
It's exactly this kind of thing that lead me away from C++. There are far too many gotcha's and tricks you need to know to write good C++.
android2over 14 years ago
"To work correctly, classes with virtual methods must also have virtual destructors."<p>Not a good way to start the article... I immediately question the author's credibility following this statement.
评论 #1903890 未加载
jimwiseover 14 years ago
All of which is a workaround for the fact that there is no explicit way to declare a c++ class to be abstract-only.<p>What happens if you do have shared logic to put in the abstract base class's destructor? It can't be pure virtual, and you're back to being able to instantiate your 'abstract' base class...
评论 #1904071 未加载
评论 #1903998 未加载
measthamover 14 years ago
I didn't know you could define member functions that were declared pure virtual. The more you know..