xxxxxxxxxx
Is used to declare a reference to other variables and such.
xxxxxxxxxx
int sum1 = 100 + 50; // 150 (100 + 50)
int sum2 = sum1 + 250; // 400 (150 + 250)
int sum3 = sum2 + sum2; // 800 (400 + 400)
xxxxxxxxxx
// CPP Program to demonstrate the Binary Operators
#include <iostream>
using namespace std;
int main()
{
int a = 8, b = 3;
// Addition operator
cout << "a + b = " << (a + b) << endl;
// Subtraction operator
cout << "a - b = " << (a - b) << endl;
// Multiplication operator
cout << "a * b = " << (a * b) << endl;
// Division operator
cout << "a / b = " << (a / b) << endl;
// Modulo operator
cout << "a % b = " << (a % b) << endl;
return 0;
}
xxxxxxxxxx
//if both statements are true, return True
//if neither is true or one is false, return True
xxxxxxxxxx
string s = "Hello, wordl";
string* p = &s; // Here you get an address of s
string& r = s; // Here, r is a reference to s
s = "Hello, world"; // corrected
assert( s == *p ); // this should be familiar to you, dereferencing a pointer
assert( s == r ); // this will always be true, they are twins, or the same thing rather
string copy1 = *p; // this is to make a copy using a pointer
string copy = r; // this is what you saw, hope now you understand it better.
xxxxxxxxxx
(pointer_name)->(variable_name)
The -> operator in C or C++ gives the value held by variable_name to structure or union variable pointer_name.