This tutorial will actually be a continuation of the topics covered in the last tutorial of Virtual Functions but this will be a fuller explanation of what virtual functions are and how they can be used in a program. We will present a simple database program with a virtual function to show how it can […]
Sometimes we need to handle limited set of values which can be referred by labels. For example the day of week, year names etc…
This concept in C/C++ is called enumeration. Here thisWeek is the variable of enum type week.
The enumerated type is used in C++ in exactly the same way it was used in […]
We can say the pointer as a variable which holds the memory address of another variable. If one variable contains the address of another variable, the first variable is said to point to the second.
Declaring a Pointer
If a variable is holding the address of another variable then we can declare it as
Here var_type is the […]
The purpose of this tutorial is to illustrate how to use some of the traditional aspects of C or C++ with classes and objects. Pointers to an object as well as pointers within an object will be illustrated. Arrays embedded within an object, and an array of objects will be illustrated. Since objects are simply […]
A constructor is a special method that is created when the object is created or defined. This particular method holds the same name as that of the object and it initializes the instance of the object whenever that object is created. The constructor also usually holds the initializations of the different declared member variables of […]
Exceptions are the way of flagging unexpected conditions or errors that have occured in C++ program.
so far we have handled error conditions by using the if statement to test some expressions and then executing specific code to deal with the error. C++ Language provides a good mechanism to tacke these conditions. The exception mechanism
As opposed to a constructor, a destructor is called when a program has finished using an instance of an object. A destructor does the cleaning behind the scenes. Like the default constructor, the compiler always create a default destructor if you don’t create one. Like the default constructor, a destructor also has the same name […]
What is Operator Overloading
Operator Overloading enables us to make the standard operators, like +, -, * etc, to work with the objects of our own data types. So what we do is, write a function which redefines a particular operator so that it performs a specific operation when it is used with the object of […]