Bit shift operators for IO

suggest change

The operators << and >> are commonly used as “write” and “read” operators:

The way they do this is similar if you wanted to overload them “normally” outside of the class/struct, except that specifying the arguments are not of the same type:

Example:

//Overload std::ostream operator<< to allow output from Vector's
std::ostream& operator<<(std::ostream& lhs, const Vector& rhs)
{
    lhs << "x: " << rhs.x << " y: " << rhs.y << " z: " << rhs.z << '\n';
    return lhs;
}

Vector v = { 1, 2, 3};

//Now you can do
std::cout << v;

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:


Operator overloading:
* Bit shift operators for IO

Table Of Contents
8 Arrays
11 Loops
39 Streams
51 Unions
55 Operator overloading
56 Lambdas
60 SFINAE
62 RAII
67 Sorting
84 RTTI
87 Scopes
104 Profiling
107 Recursion
117 Iteration
125 Alignment
134 Semaphore
136 Debugging
139 Mutexes
142 decltype