| 1 | #include <stdio.h> |
| 2 | #include <memory> |
| 3 | |
| 4 | class BaseClass |
| 5 | { |
| 6 | public: |
| 7 | BaseClass(); |
| 8 | virtual ~BaseClass() { } |
| 9 | }; |
| 10 | |
| 11 | class DerivedClass : public BaseClass |
| 12 | { |
| 13 | public: |
| 14 | DerivedClass(); |
| 15 | virtual ~DerivedClass() { } |
| 16 | protected: |
| 17 | int mem; |
| 18 | }; |
| 19 | |
| 20 | BaseClass::BaseClass() |
| 21 | { |
| 22 | } |
| 23 | |
| 24 | DerivedClass::DerivedClass() : BaseClass() |
| 25 | { |
| 26 | mem = 101; |
| 27 | } |
| 28 | |
| 29 | int |
| 30 | main (int argc, char **argv) |
| 31 | { |
| 32 | BaseClass *b = nullptr; // Break here and check b has 0 children |
| 33 | b = new DerivedClass(); // Break here and check b still has 0 children |
| 34 | b = nullptr; // Break here and check b has one child now |
| 35 | return 0; // Break here and check b has 0 children again |
| 36 | } |
| 37 | |