Smart pointer in C++

 

Introduction

It is a set top box company. I was there as an software engineer developing software in C++ with some old tool chain which does not come with shared point from the standard library. Memory management is one of the fundamental issues. Here is a small showcase showing a simple smart pointer in C++ for memory management.

Showcase set up



We have 2 cases in this showcase. The first one shows a simple scenario that we only have a simple class. The second one shows cases that we have a inheritance.

Result

$ ./app/SmartPointer/SmartPointer

Start simple case ==============
Hello from constructor
Hello from Foo
Hello from destructor
Hello from END
Case done ======================

Start inherit case ==============
Hello from BaseClass constructor
Hello from ChildClass constructor
Print from Base Hello from ChildClass Print
Hello from END
Hello from ChildClass Print
Hello from END
Hello from ChildClass destructor
Hello from BaseClass destructor
Case done ======================

Code

Gitlab example

Comments