Posts Tagged ‘oop’

Introduction to Classes in Object Oriented Programming C++

Written by Hamza. Posted in C++

classes in C++

You may recall i started a  series about the basics of object oriented programming in C++. This is the second article of the series. Here, I give you an introduction to classes in C++, explaining about the basic syntax and structure, giving an example to illustrate just how to instantiate and use an object after declaring a class. 

Operator Overloaded Functions as Non-Member Functions

Written by Raza. Posted in C++

overloading addition operator

C allows almost all the operators to be overloaded both as member and non-member functions. Up till now we have overloaded all the operators as member functions. Today we shall overload addition operator for our class as a non-member function. We shall also look at the advantages and disadvantages of declaring an overloaded function for the operator as a non-member function. 

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 Post Increment Operator (++)

Written by Raza. Posted in C++

Post increment operator

Last time we saw how to overload pre increment operator in our Fraction class as a member function. Post increment operator and pre increment operator are identical in their syntax. Both are written as (++) and used in exactly the same way except to their position before and after the variable. So how to overload the post increment operator in your class? I will show you how to do this in this article. 

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.