Overloading Increment Operator

C++-Overloading Increment Operator

Overloading Increment Operator Both increment and decrement operators have two versions in C-the prefix version and the postfix version. They are differentiated by their position in C and C++ as well, which we can specify by overloading. We need to pass a dummy argument in the case of postfix operators. Consider the following program, when … Read more…

Using Friends for Overloading > Operators

C++-Using Friends for Overloading Input and Output Operators

Using Friends for Overloading << and >> Operators It is simple to use cout and cin for reading and writing built-in type data. We can also use them for user-defined objects. Consider the following statement: The cout is an object representing an output stream. A stream is very analogous to a pipe. The cout takes … Read more…

Overloading Operators Using Friends

C++-Overloading Operators Using Friends

Overloading Operators Using Friends Operator functions must be either member functions or friend functions. A basic difference between them is that a friend function will have only one argument for unary operators and two for binary operators, while a member function has no arguments for unary operators and only one for binary operators. This is … Read more…

Overloading Unary Operators

C++-Overloading Unary Operators

Overloading Unary Operators All operators having a single argument are unary operators. When we overload these operators as member functions, we do not need to pass any argument explicitly. The this pointer pointing to invoking object is passed as an implicit argument. Let us consider the unary minus operator. We know that this operator changes … Read more…

Operator Overloading

C++-Operator Overloading

Operator Overloading Operator overloading is one of the many exciting features of c++ language. It is an important technique that has enhanced the power of extensibility of c++. C++ tries to make the user defined data types behave inĀ  same way as the bulit-in types. For instance, C++ permits us to add two variables of … Read more…