- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What are the new changes introduced in C++11?
C++11 is a version of standard C++ language. It was approved by International Organization for Standardization (ISO) on 12 August 2011 then C++14 and C++17. C++11 makes several additions to the core language.
There are some of the new changes introduced in C++11 −
nullptr − In the previous nullptr, zero used to be the value and it had a drawback of implicit conversion to integral value. The null pointer literal is represented by std::nullptr_t. In this nullptr, no implicit conversion exists.
Lambdas − The lambda expression allows to define functions locally. Anonymous functions are known as lambda. We can use lambda expression wherever the function object std::function is expected.
Smart pointers − The smart pointer auto_ptr was the only smart pointer and now it is deprecated. There are three other smart pointers are added in C++11 i.e. shared_ptr, unique_ptr and weak_ptr.
auto − In previous versions, we must specify the type of the object but in C++11, there is no need to specify the type which means you can declare the variables directly without specifying their type.
Override and Final − The version C++11 has introduced two new special identifiers i.e. override and final. Override indicates that the method is supposed to be override of virtual method in base class. On the other hand, final indicates that derived class should not override the virtual method.
Deleted and defaulted functions − The deleted functions are useful for preventing object copying. To disable copying, “ =delete; “ is used. The default function gives instruction to the compiler to generate default implementation of function and “ =default; “ is used for default functions.
Range-based for loops − C++11 introduced range-based for loops for iterating over collections. Now, it is possible to iterate over like C-arrays. It supports ‘foreach’ paradigm of iterating over.
Strongly-typed enums − In the traditional enums, They used to export their enumerators in surrounding scope. They are specified as “enum class” keyword. They do not export their enumerators in surrounding scope.
Static_assert and type traits − It performs an assertion check at the time of compilation. If the assertion is true, it displays nothing otherwise it displays an error message.
New C++ algorithms − The C++11 standard library introduced new algorithms with some operations like all_of(), any_of and none_of().
- The Biggest Changes in C++11
- What are the new types introduced in HTML for input type?
- What are the differences between -std = c++11 and -std = gnu++11?
- Which are the new Null Operators introduced in PowerShell version 7?
- What changes has been introduced in JDK7 related to Exception handling in Java?
- What are the options and variables introduced in MySQL 8.0?
- What are the main features and enhancements introduced in Java 9?
- What are the changes in Memory Management in Java 9?
- Why are interfaces introduced in Java?
- What are the changes of class loaders in Java 9?
- What is the difference between C++0x and C++11?
- C++11 Overview
- What is Rule of Five in C++11?
- What is a lambda expression in C++11?
- What are the core library changes in Process API in Java 9?