Maintaining Classes in Separate Files in C++

Written by Hamza. Posted in C++

header and definition files

I previously mentioned in Basics of Object Oriented Programming that the main body of any class that we write in our program is usually written in a separate file called .cpp file and its declarations in another header file .h file. This is done in order to avoid clustering of the class definition with the execution body of the program. It makes it pretty easy and efficient to put all the classes in separate files in a large program. This is then included later in a main file and its functions are used in the manner we like. Here is the detailed procedure for it. 

Overloading Indexing Operator ([ ])

Written by Raza. Posted in C++

overloading indexing operator in c++

Up till now we have overloaded assignment operator and then the addition operator. One another operator which we quite frequently use in our program and thus need to redefine for ourselves is the indexing operator ([ ]). Indexing operator in in fact used to dereference a given index of the array. After overloading indexing operator, we can directly dereference the object for our particular index. Let us see how we can efficiently do this.

Switch Statement Fall through in C++

Written by Ali. Posted in C++

switch statement

Hello everyone. The topic we are about to discuss in the bugs removing section today is switch statement. Switch statement though easies up the coding efficiency by reducing the number of if-else statements but if some technical aspects of switch statement are not taken into consideration, fatal coding errors can result. Switch statement fall through in C programming can tend to be really tedious to find and hard to debug.