Author Archive

Inside Swapping

Written by Raza. Posted in C++

swapping variables

So I have decided to put aside Sorting for some time and intended to discuss a few tidbits with you. This time I would share some interesting material on the swapping of two different variables. Swapping is one of the most frequently occurring processes taking place inside a Computer Machine. Then in many other Programs and Algorithms, swapping takes place as a sub-process. Sometimes it is user defined and sometimes not. So let us see how can we improve the swapping process.

Writing a Good Constructor

Written by Raza. Posted in C++

Constructor on work

Working with pointers in C requires a lot of practice to avoid memory leaks and dangling pointers. We discussed them in length in the previous post, Pointer Hazards in C . In object oriented paradigm, whenever you declare an object of user defined class type, a special function known as constructor is automatically invoked. Similarly when you want to copy an object to another object, copy constructor gets invoked. Writing an efficient and error free constructor is essential to the construction of a good program. In this post I shall explain how to write a good and efficient constructor and a copy constructor, paying special attention to pointer hazards.

Having Fun with CStrings

Written by Raza. Posted in C++

cstrings transferring data

After some really heavy programming concepts, let us explore some lighter side of programming for a while and then we’ll return back to where we started. This time we would have a go at  Cstrings. Cstrings are character arrays having a null terminator ‘\0’ at its end. Right. So lets see what we are trying to do.

 

Some Discourse on Sorting

Written by Raza. Posted in C++

 

Sorting means to arrange the given list of data in any particular form or order. Generally sorting is done on the basis of numerical order and alphabetical or lexicographical order. Here we shall be discussing only the numerical order. In Computer Science, sorting has always been given special attention and interest because it is a vital part of many other fundamental processes. Still now, research is going on to improve the sorting techniques and numerous algorithms have been presented for this purpose. Some basic ones which are commonly used are selection sort, bubble sort, insertion sort, merge sort, shell sort, quick sort, etc.  

Overloading Addition Operator (+)

Written by Raza. Posted in C++

overloading addition operator

While working with classes, we often want to have the user defined functionalities which help enormously during the rest of the program. When we deal a lot with arrays, we often want to add the contents of two arrays into a single larger array. This could tediously be done by declaring another array of the combined size of the two and adding them one by one in it. The better option to do this is to overload the addition operator ( ) once which saves us doing this process repeatedly if we add two arrays time and again in our program. Let us see how we can do that efficiently.