June 2018
Intermediate to advanced
348 pages
8h 45m
English
If you have been programming in C++ for a long time, you might be familiar with the fact that C++ references help you to alias a variable and you can do assignment to the references to reflect the mutation in the variable aliased. The kinds of reference supported by C++ were called lvalue references (as they were references to variables that can come in the left side of the assignment). The following code snippets show the use of lvalue references:
//---- Lvalue.cpp#include <iostream>using namespace std;int main() { int i=0; cout << i << endl; //prints 0 int& ri = i; ri = 20; cout << i << endl; // prints 20}
int& is an instance of lvalue references. In Modern C++, there is the notion of rvalue references. rvalue is defined ...