Siksha Sarovar

Siksha Sarovar (sikshasarovar.com) is a free educational web application that helps students in India learn programming and prepare for academic and competitive exams. The platform offers structured coding courses (C, C++, Python, Java, HTML, CSS, PHP, Power BI, AI, Machine Learning, Data Science), complete university curriculum notes for BCA/MCA students with previous year question papers, Class 10 and Class 12 CBSE/HBSE school notes, and dedicated preparation material for SSC, UPSC, Banking, Railway and other government exams. Browsing the site is completely free and requires no account. Users may optionally sign in with Google solely to save their learning progress, quiz scores and personal preferences across devices.

Privacy Policy | Terms of Service | Contact Siksha Sarovar | About Siksha Sarovar

v4.0.9 · PWA
Siksha Sarovar logo
Siksha Sarovar
Your Learning Universe

Siksha Sarovar is a free e-learning platform for coding courses, BCA university notes and competitive exam preparation. Optional Google sign-in saves your learning progress across devices.

Initializing knowledge base…
Compiling modules 0%

Modern C++ (C++11 to C++20)

Lesson 48 of 53 in the free Foundation of C & C++ notes on Siksha Sarovar, written by Rohit Jangra.

Not Your Grandpa's C++

If you look at C++ code from 1995 and C++ code from 2024, they look like different languages. Modern C++ is much safer, faster, and easier to write.

Key Modern Features:

1. The auto Keyword (C++11)

Let the compiler figure out the type for you.

auto x = 5; // int
auto s = "hello"; // const char*

2. Range-Based For Loops

The easiest way to loop through a container.

for (int x : myVector) { cout << x; }

3. Smart Pointers (Memory Safety)

Forget delete! Smart pointers automatically free memory when no one is using it anymore.

  • unique_ptr: One owner only.
  • shared_ptr: Multiple owners using reference counting.

4. Lambda Expressions

Functions without names that you can write inside other functions. Great for sorting!

sort(v.begin(), v.end(), [](int a, int b) { return a > b; });

5. Concepts and Ranges (C++20)

Advanced tools that allow you to write "Templates" that are much easier to understand and debug.

If you're starting a new project today, always use at least C++17. It removes many of the "pain points" of older versions.