Posts Tagged ‘operator overlaoding’

Overloading Plus Equal operator (+=)

Written by Raza. Posted in C++

Plus equal operator overloading

There are various types of operators in C++. In our recent posts, we have covered overloading of a bunch of arithmetic operators. There are some arithmetic operators which perform compound functions. It means they handle more than one mathematical function at a time. The Plus Equal or Addition Assignment Operator or plus equals to operator (+=) is one of these. As the name implies, it adds and assigns the value to the variable at the same time. The plus equal operator is quite often used in programming. We shall learn how to overload it. 

Overloading Pre Increment Operator(++)

Written by Raza. Posted in C++

pre increment happening

C supports a number of arithmetic and logical operators. Post and Pre Increment operators are one of these arithmetic operators. These incremental operators add up one to existing value of the variable.The difference between post increment and pre increment is obvious from their name: post increment is placed after the variable and pre increment is placed before the variable. In principle, there is a slight difference in their behavior which I shall explain to you in this article.

 

Overloading Extraction Operator (>>)

Written by Raza. Posted in C++

Data Extraction from Computer

The extraction operator is used to take input directly in objects. In Object Oriented Programming, we want everything to be as simple and close to built in data types as is possible. The concept of overloading various operators is one facet of this need. For input and output, we especially want ease and smooth syntax to flow throughout the program.We saw how to overload insertion operator for taking output in our program. This time we shall see how to overload the extraction operator (>>) for taking input directly in an object.  

Overloading Insertion Operator (<<)

Written by Raza. Posted in C++

inserting data in the computer

We have been discussing rather overloading various operators in the object oriented paradigm in the past. Overloading operators in our class is solely for our own benefit and effectiveness of the program. It saves us from writing lengthy complicated code over and over again. When we work with objects and there is an Array inside that object, we would certainly want to output it time and again. Instead of making a loop for that every time, we overload the insertion operator (<<) once and for all which is used to cout the data on our screen. Let us see how to do that. 

Overloading Error Free Assignment Operator

Written by Raza. Posted in C++

Overloading Assignment Operator in Object Oriented Paradigm

Assignment is not a simple task in object oriented programming. It may take you a day to trace out an error that is happening because of incorrect assignment, let alone fix it. In a post before, I dealt with some issues while assigning one object to another. Still there are some issues associated with it. So I shall write a code and explain to you its errors. Kindly Follow this piece of Code.