C++11 features in Visual Studio 2015

C++ProgrammingServer Side Programming

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. Visual C++ implements the vast majority of features in C++11.

Some of the following C++11 features in Visual Studio 2015 −

  • nullptr − In the previous nullptr, zero used to be the value and it had a drawback ofimplicit 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.

  • 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 an 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 the compiler to generate default implementation of function and “ =default; “ is used for default functions.

  • 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.

  • 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.

raja
Published on 24-Oct-2018 12:57:44
Advertisements