Using inline functions for C++ Programming

In C/C++, we use the qualifier inline before a function’s return type in the function definition to “advise” the compiler to generate a copy of the function’s code in place to avoid a function call.

But why do we need to avoid function call? Well, the only reason is to reduce execution time, though it comes with a small disadvantage of increasing of program size. Function calls requires the program to insert parameters and return address into stacks before jumping to the entry point of the called function. The return address needs to be retrieved from the stack upon exit of the called function. All these are overheads to execution time, and if a certain function is to be called very frequently, it might be a good idea to make it an inline function.

So, just a little tip in C programming which might be useful.

Object-Oriented Programming (OOP) Concepts

I used to give C++ training to the younger programmers of my ex-company. So over time I managed to compile my own teaching materials and tutorials.
Since we started this blog to share what we know, I guessed perhaps I can contribute a little bit about C++ programming and OOP concepts.

What is OOP ? It is a programming implementation style that supports the following concepts:

• Abstraction
The ability of packing data together with functions, that allows you to create a new data type.

• Encapsulation
Encapsulation is the property of being a self-contained unit. The encapsulated unit can be used without regard about how it works internally.

• Inheritance
Inheritance is the process whereby one object acquires the characteristics of one or more objects.

• Polymorphism
Polymorphism refers to the same name taking many forms.

The above are the key concepts behind Object-Oriented Programming (OOP). Different object-oriented languages like C++, Java, etc will have slightly different implementation but the key concepts would be the same.