Note that the tutorials are displayed in order of difficulty! (From beginner to experienced.)

File IO in C++ (text and binary files) part II

In the first C++ programming tutorial on file IO we looked at the theory behind file IO.

In this second C++ programming tutorial on file IO we will look at some examples. More »


Posted in C++ Tutorials | 6 Comments


C++ Tutorial – Namespaces and anonymous namespaces

Namespaces are used in the C++ programming language to create a separate region for a group of variables, functions and classes etc. Namespaces are needed because there can be many functions, variables for classes in one program and they can conflict with the existing names of variables, functions and classes. C++ uses namespace to avoid the conflicts.

The concept can be depicted using the following diagram: More »


Posted in C++ Tutorials | 7 Comments


C++ Overloading and Operator Overloading

In the C++ programming language overloading is used for performing more than one task using the same function or operator. For overloading of the functions we create two or more definitions of one function name.

Take a look at an example: More »


Posted in C++ Tutorials | 7 Comments


C++ Unary and binary operator overloading and static members

We hope that you enjoyed our previous tutorial on C++ overloading. Today we take another look at operator overloading in the C++ programming language.

Unary and binary operator overloading

There are two types of operator overloading: More »


Posted in C++ Tutorials | 24 Comments


C++ Inheritance

Inheritance is a concept of linking two or more classes with each other in a hierarchical manner so that their properties and functions can be shared. (One class will extend to another class.) This leads to the biggest advantage of re-usability of the members and avoids redundancy.

Inheritance leads to various issues such as: More »


Posted in C++ Tutorials | 33 Comments


C++ Friend function and Friend class

In the last C++ programming tutorial we looked at inheritance. In this C++ programming tutorial we will take a look at C++ friendship.

Friend Functions

A C++ friend functions are special functions which can access the private members of a class. They are considered to be a loophole in the Object Oriented Programming concepts, but logical use of them can make them useful in certain cases. More »


Posted in C++ Tutorials | 37 Comments


C++ Templates

C++ templates are a powerful mechanism for code reuse, as they enable the programmer to write code that behaves the same for data of any type. So we can view templates as molds which can create many shapes of similar types with any type of material filled into them.

Templates are also known as generic functions or classes which are used to implement a generic structure for many structures of the same statements with different data-types. More »


Posted in C++ Tutorials | 1 Comment


C++ Polymorphism and Abstract Base Class

Before you start reading this C++ tutorial on polymorphism you should have a good understanding of class inheritance and pointers.

Introduction to Polymorphism

Polymorphism is by far the most important and widely used concept in object oriented programming. Some of the widely used technologies and libraries like COM, MFC etc. have polymorphism as their foundation. If you look at all the original design patterns, almost every pattern uses polymorphism in its structure. More »


Posted in C++ Tutorials | Comments Off on C++ Polymorphism and Abstract Base Class


C++ Exceptions and exception handling

Exceptions are situations which must be avoided during program executions. Exceptions are caused by errors, invalid inputs or invalid processing. Exceptions can lead to either program termination or generating unexpected outputs.

In general, it is assumed that exceptions are errors but this is not always true. We can state: More »


Posted in C++ Tutorials | 2 Comments


C++ Typecasting Part 1

Typecasting is the concept of converting the value of one type into another type. For example, you might have a float that you need to use in a function that requires an integer.

Implicit conversion

Almost every compiler makes use of what is called automatic typecasting. It automatically converts one type into another type. If the compiler converts a type it will normally give a warning. For example this warning: conversion from ‘double’ to ‘int’, possible loss of data. More »


Posted in C++ Tutorials | 6 Comments