# What is Modern C++ and its features C++ have the highly optimized libraries, it allows us to access the low level hardware features to maximize the performance speed and minimize the memory consumption. This is what makes it a must to have programming language in the list of all [web designing institute in delhi](https://www.admecindia.co.in/courses/web-design-courses/) as well as [Web Development Training in Delhi](https://www.admecindia.co.in/courses/web-development-courses/) for students. Modern features of the c++ Some of the modern features of c++ is explained below: Resources and smart pointers In the C language one of the major bugs were the memory leaking. This got solved in C++. Let’s see an program to understand it better: #include <memory> class widget { private: std::unique_ptr<int> data; public: widget(const int size) { data = std::make_unique<int>(size); } void do_something() {} }; void functionUsingWidget() { widget w(1000000); // lifetime automatically tied to enclosing scope // constructs w, including the w.data gadget member // ... w.do_something(); // ... } // automatic destruction and deallocation for w and w.data Standard library algorithms C++ have some statndard library algorithm that is indeed very useful when it comes to containing the growing algorithms such as searching, sorting, filtering and randomizing. Let’s see some of the important examples: for_each transform find_if sort, lower_bound auto instead of explicit type names auto keyword is being introduced in the c++, to use it in function and template declarations. Here is an example of code: map<int,list<string>>::iterator i = m.begin(); // C-style auto i = m.begin(); // modern C++ Range based for loops The old style of iteration in C language over the arrays and containers are prone to indexing errors, to eliminate these errors and make the code more readable we do use the user range based for loops. Here is an example for you to understand: #include <iostream> #include <vector> int main() { std::vector<int> v {1,2,3}; // C-style for(int i = 0; i < v.size(); ++i) { std::cout << v[i]; } // Modern C++: for(auto& num : v) { std::cout << num; } } Constexpr expression instead of macros In C language we do need to use the macros but in c++ we have the tokens that are preprocessed before the compilation of the code. The instance of macro token is replaced with it’s defined values or the expression before the time of the execution. Let’s see an example of code: #include <vector> struct S { std::string name; float num; S(std::string s, float f) : name(s), num(f) {} }; int main() { // C-style initialization std::vector<S> v; S s1("Teena", 2.7); S s2("Rashmi", 3.5); S s3("Anu", 85.9); v.push_back(s1); v.push_back(s2); v.push_back(s3); // Modern C++: std::vector<S> v2 {s1, s2, s3}; // or... std::vector<S> v3{ {"Teena", 2.7}, {"Rashmi", 3.5}, {"Anu", 85.9} }; } These were the some of the modern c++ features with some example explanation. Now it’s your turn for learning these concepts in detail. Check web design course in Delhi to learn the codding from basics. If you are looking for learning this language especially then you can join a [C++ course in Delhi](https://www.admecindia.co.in/course/advanced-c-plus-plus-master-course/). Learning this programming language is must for all who are pursuing a [diploma in web design and development](https://www.admecindia.co.in/course/advanced-web-design-development-master-course/) in Delhi and want to become a web designer or web developer.