# Section 24: C++ 11

## Auto

1. auto can detect the data type, so you don’t need to declare the data type by yourself. decltype can capture the data type and use it on the other variables.

## Final Keyword

1. If you use final keyword, it will restrict inheritance. Moreover, final function can’t be inherited by the derived class.

## Lambda Expressions

1. Lambda is useful for defining unnamed function, so we can define the function wherever we like.
2. The format of lambda expression: [capture_list](parameter_list)->returnType{ body };
3. Example.

## Smart Pointers

1. unique_ptr: Upon an object at a time only one pointer will be pointing.
2. shared_ptr: It can be used by more than one pointer can point on the same object. It has Ref_counter to record how many pointers point to an object and you can use use_count() to check it. If the Ref_counter becomes to zero, the object will be deleted.
3. weak_ptr: It doesn’t have the Ref_counter. Suppose the pointers are holding the objects and requesting for other objects, then they may form a deadlock between the pointers. So to avoid a deadlock, weak pointers are useful. This is between unique and share, but it’s not strict.
4. unique_prt example.
5. share_ptr example.

## InClass Initializer and Delegation of Constructor

1. One constructor can call another constructor in the same class. Here is an example.

## Ellipsis

1. Ellipsis is used for taking variable number of arguments in a function. Here is an example.

# Disclaimer

I took this course from Udemy, which is Learn C++ Programming -Beginner to Advance- Deep Dive in C++. I only took some notes of this amazing course for my personal future uses and share my thoughts with my peers. If you like it, you should take the course from Udemy too.

Share