C++ 11

Join & Detach Threads in C++11 / C++14? Multithreading – Part 2

In this article we will discuss about joining and detaching of std::thread. Joining Threads with std::thread::join() Once a thread is started, then that thread is a joinable thread. Another thread can wait for this new thread to finish. For this another need need to call join() function on the std::thread object i.e. Lets understand this

Join & Detach Threads in C++11 / C++14? Multithreading – Part 2 Read More »

How to Create Threads in C++11 / C++14? | Multithreading – Part 1

In this lecture, we will learn how to create threads in C++ using std::thread. Introduction to the C++11 Thread Library The original C++ Standard supported only single-threaded programming. However, the new C++ Standard, often referred to as C++11 or C++0x, was published in 2011. With C++11, a new thread library was introduced. Compilers Required:– Linux:

How to Create Threads in C++11 / C++14? | Multithreading – Part 1 Read More »

What is weak_ptr in Modern C++ & why do we need it?

In modern C++ programming, smart pointers provides automatic memory management. Among these smart pointers, shared_ptr is widely used because it takes care of releasing memory when it is no longer needed, thanks to reference counting. However, misusing shared_ptr can lead to issues like memory leaks, especially in complex data structures such as binary trees. Let’s

What is weak_ptr in Modern C++ & why do we need it? Read More »

How not to use Smart Pointers in C++?

In modern C++, std::shared_ptr is a smart pointer that manages shared ownership of a dynamically allocated object. It is part of the C++ Standard Library’s memory header. Shared pointers keep track of how many objects own a particular resource and automatically delete the resource when there are no owners left. However, if not used carefully,

How not to use Smart Pointers in C++? Read More »

Smart Pointer vs Raw Pointer in C++

In this article, we will compare the C++11 Smart Pointer implementation shared_ptr with a normal pointer. Missing ++, – – and [] operators in shared_ptr While shared_ptr in C++ offers robust memory management and facilitates collaborative ownership of resources, it intentionally lacks some operators that are available to raw pointers. This is primarily to prevent

Smart Pointer vs Raw Pointer in C++ Read More »

What is shared_ptr in C++?

In this article, we will discuss one of the most used Smart Pointers in C++: shared_ptr. What is std::shared_ptr<>? The std::shared_ptr is a smart pointer class provided by C++11. Multiple std::shared_ptr objects can point to same dynamically allocated memory. It ensures automatic deletion of the associated memory when there are no more shared_ptr instances pointing

What is shared_ptr in C++? Read More »

Scroll to Top