Created
February 9, 2015 13:23
Revisions
-
junfeng_hu created this gist
Feb 9, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,41 @@ #include <iostream> class Base { public: Base() { std::cout << "Base Constructor" << std::endl; ctor(); } virtual ~Base() { std::cout << "Base Destructor" << std::endl; dtor(); } virtual void ctor() { std::cout << "in Base::ctor" << std::endl; } virtual void dtor() { std::cout << "in Base::dtor" << std::endl; } }; class Derived: public Base { public: Derived() { std::cout << "Derived Constructor" << std::endl; ctor(); } ~Derived() { std::cout << "Derived Destructor" << std::endl; dtor(); } virtual void ctor() { std::cout << "in Derived::ctor" << std::endl; } virtual void dtor() { std::cout << "in Derived::dtor" << std::endl; } }; int main() { Base *pb = new Derived(); delete pb; }