diff --git a/.vimrc b/.vimrc index 4e1836f..00447e6 100644 --- a/.vimrc +++ b/.vimrc @@ -19,6 +19,7 @@ set backspace=indent,eol,start color backbone set number nmap :set invlist +set breakindent " https://www.linux.org.ru/forum/general/10615635?lastmod=1403800233259 " Setup for the GNU coding format standard function! GnuIndent() diff --git a/dev/cpp/virtual_destructor/virtual_destructor.cpp b/dev/cpp/virtual_destructor/virtual_destructor.cpp new file mode 100644 index 0000000..680fc5f --- /dev/null +++ b/dev/cpp/virtual_destructor/virtual_destructor.cpp @@ -0,0 +1,31 @@ +#include + +using namespace std; + +class A1 { + public: + A1 () { + cout << "A1() called" << endl; + } + + virtual ~A1 () { // won't be called if non-virtual + cout << "~A1() called" << endl; + } +}; + +class A2 : public A1 { + public: + A2 () { + cout << "A2() called" << endl; + } + + ~A2 () { + cout << "~A2() called" << endl; + } +}; + +int main (int argc, char *argv[]) +{ + A1 *ap = new A2(); + delete ap; +}