Posts Tagged ‘object oriented programming’

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. 

Templates in C++

Written by Raza. Posted in C++

Templates in C++

A technique quite frequently employed in Object Oriented Paradigm and otherwise is known as Generic Programming. Generic Programming is a concept using which you a user can write a code which works well for many data types. In other words, it is type independent programming. A function made generic does not need to know what kind of data type it is receiving. Generic programming is made possible through a feature known as templates. Templates allow functions and classes to operate with these generic or types. I shall explain you why we need templates and how do we employ them.

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.