`
桥下一粒砂
  • 浏览: 206273 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

【C++】Virtual method but non-virtual destructor

    博客分类:
  • C++
阅读更多
有虚函数(纯虚函数)就应该有虚析构函数。


class Base
{
public:
    virtual void func() = 0;
    virtual ~Base() {}; // 注意,有{}实现
};

class Child : public Base
{
public:
    void func()
    {
    };

    ~Child(){ ... };
}


特记录下来。
分享到:
评论

相关推荐

    Selected.Topics.in.Cplusplus.15117

    Non-Constructible, Non-Copyable Class Understanding new Understanding Constructors Forward Declarations, Compiling and Linking Copy Constructor and Object Cloning Class Member Access Class member ...

    game-destructor:由GitHub Classroom创建的game-destructor

    game-destructor:由GitHub Classroom创建的game-destructor

    Google C++ Style Guide(Google C++编程规范)高清PDF

    As every C++ programmer knows, the language has many powerful features, but this power brings with it complexity, which in turn can make code more bug-prone and harder to read and maintain....

    FlexGraphics_V_1.79_D4-XE10.2_Downloadly.ir

    - ADD: Add TFlexPanel.InvalidateControl virtual method which calls from TFlexControl.Invalidate and can be overriden (it is possible now to catch all object invalidation calls). - FIX: The TFlexPanel....

    More Effective C++.pdf

    某些小范围主题诸如「在base classes 中使用virtual destructor」、「令operator= 传回*this 的reference」,可能在百科型C++ 语言书籍中亦曾概略提过,但此类书籍以深度探索的方式,让我们了解问题背後的成因、最佳...

    More Effetive c++

    主题诸如「在base classes 中使用virtual destructor」、「令operator= 传回*this 的reference」,可 能在百科型C++ 语言书籍中亦曾概略提过,但此类书籍以深度探索的方式,让我们了解问题背後的成因、 最佳的解法、...

    Effective+C+++3rd+chm+中文版(代码加亮)

    destructor(析构函数)什么时候应该是 virtual(虚拟)的?当 operator new(运算符 new)找不到足够的内存时它应该怎么办?类似这些的令人费神的细节是至关重要的,因为错误的做法几乎总是导致无法预料的,很可能...

    Cookie DestrucTor-开源

    Cookie DestructoR可帮助您维护网络隐私。 该软件具有即时清除Cookie和Internet缓存的功能。 如有必要,可以销毁计算机上的Index.dat数据库文件。

    More Effective C++(中文版)

    某些小范围主题诸如「在base classes 中使用virtual destructor」、「令operator= 传回*this 的reference」,可能在百科型C++ 语言书籍中亦曾概略提过,但此类书籍以深度探索的方式,让我们了解问题背后的成因、最佳...

    Computer Destructor-开源

    这是你应该完全拥有它的最棒的 pwogwam eva! 啊啊啊啊

    windowsmain directx device font virtual button dll array 0.3

    Library file destructor-free version He's an example of a C-function

    ruby-destructor:Ruby 的析构函数

    gem 'destructor' 然后执行: $ bundle 或者自己安装: $ gem install destructor 用法 require 'destructor' class Foo attr_reader :bar def initialize @bar = 123 end def finalize puts ...

    C++中确定基类有虚析构函数

    本文给大家介绍了C++中确定基类有虚析构函数的方法。

    More Effective C++

    某些小范围主题诸如「在base classes 中使用virtual destructor」、「令operator= 传回*this 的reference」,可能在百科型C++ 语言书籍中亦曾概略提过,但此类书籍以深度探索的方式,让我们了解问题背後的成因、最佳...

    新手学习C++入门资料

    主体:(一)<C++与C语言的区别> 一、C++概述 (一) 发展历史 1980年,Bjarne Stroustrup博士开始着手创建一种模拟语言,能够具有面向对象的程序设计特色。在当时,面向对象编程还是一个比较新的理念,Stroustrup...

    C++STL程序员开发指南【可搜索+可编辑】

    第1 章C++ 编程技术...................................................... 3 1-1 C++与C 语言的区别................................................... 4 1-1-1 文件扩展名的改变,.............................

    C++虚基类 虚函数 虚析构函数

    virtual ~Base();//析构函数做成员函数 }; Base::~Base()//成员函数实现 { cout<<"Base destructor"; } class Derived:public Base { public: Derived(); ~Derived(); private: int *p; }; Derived::Derived() ...

    陈广C#程序设计入门与实例视频教程11-19.rar

    11-constructor(2).swf 12-Destructor(1).swf 13-Destructor(2).swf 14-decstructor(3).swf 15-modifier.swf 16-Conversions(1).swf 17-Conversions(2).swf 18-Property(1).swf 19-Property(2).swf

    delphi2-delphi2010 全支持 dcu 装换 pas

    + Delete procedure, contructor, destructor frame 2002-07-18 + Procedure variable const + Now can distinguish: vc1: PChar ='test'; vc2: PChar = @vc1; 2002-05-28(Ver1.1) + Now correctly process ...

    C++标准库(第二版)英文版.pdf

    The C++ Standard Library A Tutorial and Reference (2nd Edition)+cppstdlib-code.zip C++标准库(第二版)英文版.pdf 非扫描版+源代码 Prefaceto the SecondEdition xxiii Acknowledgments for the Second...

Global site tag (gtag.js) - Google Analytics