Delegating constructor is a new concept in C++ 11. Why we need delegating constructor? 1. Delegating constructor is used to prevent code duplication. 2. It is the only way to delegate the initialization list Consider the code below: #include <iostream> //for more C++ tutorial visit www.ProDeveloperTutorial.com …
“constexpr” is a new concept in C++ 11. In this chapter we shall have a look at “constexpr” topic. “constexpr” are used in the scenario, where there is a possibility to evaluate the value of the function or variable at compile time. “constexpr” is the keyword …
“nullpt” is a new concept that has been introduced in C++ 11. Earlier to C++ 11, NULL has been defined as: #define NULL 0 But after C++ 11, NULL has been defined as #define NULL nullptr “nullptr” is defined in #include <cstddef> header file. It means …
unique_ptr is a smart pointer available in C++ 11. Weak pointer is used along with shared pointers. You cannot create a standalone unique pointers. Example of weak pointer: #include <iostream> #include <memory> //for more C++ tutorial visit www.ProDeveloperTutorial.com using namespace std; class MyClass { public: MyClass() …
In this tutorial we shall see how to overload assignment operator “=”. #include <iostream> // for more tutorials check www.prodevelopertutorial.com using namespace std; class MyClass { private: int num_1; int num_2; public: MyClass(int a, int b): num_1(a), num_2(b){ } void operator = (const MyClass &obj …
In this chapter we shall see how to overload relational operators . #include <iostream> // for more tutorials check www.prodevelopertutorial.com using namespace std; class MyClass { private: int num_1; public: MyClass(int a): num_1(a){ } friend void operator < (MyClass &obj1, MyClass &obj2); friend void operator > …