Author Archive

The arrow operator (->) in C++

Written by Hamza. Posted in C++

arrow operator c++

Let us now look at another interesting feature that pops up whenever dealing with classes in C++: the arrow operator. The arrow operator is used to access member functions within a class through a pointer. It is a very useful feature and makes object oriented programming in C++ a lot easier.

Using Setters in C++

Written by Hamza. Posted in C++

setter in c++

After talking about constructors and destructors, next up in my series on object oriented programming is how to use setters. Setters are functions that are used to change the values of data members inside classes. They are very important, as they are the only route through which we can change the value of our data members after an object is instantiated.

Using getters in C++

Written by Hamza. Posted in C++

getters in C++

Now that we have had a look at setters in C++, let us move on the the use and concept of getters. Getters, or accessors, are often found alongside setters in a class, and are extremely vital in object oriented programming.

Use of Destructors in C++

Written by Hamza. Posted in C++

destructor

Now that we”ve had a look at the types and uses of constructors, let us move on to the concept and use of destructors in C . Destructors are important in object oriented programming, as they are called whenever the life of an object ends. To understand destructors, first we must know that when dealing with classes, we often encounter a situation where pointers are used. A class with a pointer/pointers as data members are usualy allocated memory in a constructor. As a simple example, let us use a class called “point”, with a redundant data member called int * ptr. 

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.