C++ (Qt)#include <iostream>class Base {public: Base() {} virtual ~Base() = 0;};// inline ~Base() {} class Derived: Base {public: Derived() {}; virtual ~Derived() { std::cout << "Derived::~Derived\n"; }}; int main() { Derived d; return 0;}
alexander@goblin /tmp $ g++ 1.cpp/tmp/cc3mCBWm.o: In function `Derived::~Derived()':1.cpp:(.text._ZN7DerivedD2Ev[_ZN7DerivedD5Ev]+0x2f): undefined reference to `Base::~Base()'1.cpp:(.text._ZN7DerivedD2Ev[_ZN7DerivedD5Ev]+0x58): undefined reference to `Base::~Base()'collect2: выполнение ld завершилось с кодом возврата 1
C++ (Qt)virtual ~Base() {}
C++ (Qt)#include <iostream>class Base {public: Base() {} virtual ~Base() = 0;}; inline Base::~Base() {} class Derived: public Base {public: Derived() {}; virtual ~Derived() {}}; int main() { int i=100500000; do { Derived d; } while(i--); return 0;}
C++ (Qt)#include <iostream>class Base {public: Base() {} virtual ~Base() {}}; class Derived: public Base {public: Derived() {}; void foo() {}; virtual ~Derived() {}}; int main() { int i=100500000; do { Derived d; } while(i--); return 0;}
alexander@goblin /tmp $ g++ 1.cpp -O0 -o test1alexander@goblin /tmp $ g++ 2.cpp -O0 -o test2alexander@goblin /tmp $ time ./test1real 0m22.259suser 0m22.254ssys 0m0.001salexander@goblin /tmp $ time ./test1real 0m22.286suser 0m22.280ssys 0m0.001salexander@goblin /tmp $ time ./test2real 0m22.312suser 0m22.263ssys 0m0.034salexander@goblin /tmp $ time ./test2real 0m22.270suser 0m22.264ssys 0m0.001s