nullptr

Let us understand the need of nullptr with help of an example. #include <iostream>using namespace std;class base {public: void display(int num) { cout << “Integer display: “ << num << endl; } void display(char* ptr) { cout << “ptr display: “ << ptr << endl; }}; int main() { base b; b.display(NULL); return 0; } The above code will not compiled. Below error will come: “In function int main():     15:15: error: call of overloaded display(NULL) is ambiguous            b.display(NULL); 15:15: note: candidates are:  …

auto keyword

Let us understand the usage of auto keyword with the help of an example. #include <iostream>using namespace std;int main(){ auto i = 10; auto d = 7.5; cout <<  “Integer and double: ” << i << “ “ << d << endl; return 0;} Above code can be compiled using -std=c++11 flag. Here, we have not defined the type for variable i and d.  When we initialize the variable at the time of declaration, compiler can identify or deduce the type for it. Based on this, C++11 came with the…

Initializer_list

Let us understand the concept of initializer_list with the help of an example: #include <iostream>#include <vector>#include <initializer_list>using namespace std;#define MAX 10class array{public: array(std::initializer_list<unsigned int> list) { index = 0; for(auto item: list) { arr[index++] = item; } cout  << “C’tor” << endl; } void display() { for (unsigned int i = 0; i < index; ++i) { cout << arr[i] << endl; } }private: unsigned int arr[ MAX]; unsigned short index;};int main(){ array arrObj = {0,1,5,7,8}; arrObj.display(); vector <unsigned int> v = {5,8,9,10,20}; cout << “Entries in vector: ” <<…