Pointer Basics in C++

A Pointer variable, just called a pointer, holds the memory address of data that is stored. Through the pointer, you can read the address, and thus indirectly access the value of the variable. To access a value, you use the dereference operators (*) to get the value stored at that memory address. To store a…

Inline Functions in C++

Calling a function has a performance penalty because you have to create variables, specify scope, pause the current variables and push data onto the call stack, just to name a few reasons. C++ allows you to define an inline function, which should be short, to improve the performance. In doing so, the compiler will actually…

Function Prototypes

In previous examples, we’ve had to write our functions above the place where they are called. However, many developers like to place main as their first function they see, so it’s easier to find. Or they may not know the order that the function will be called. C and C++ allow you to define a…

Overloading a Function

Overloading a function means that you can create different functions with the same name, as long as their signatures are different. That means that the parameter list must be of a different number and/or data types from one to another. Overloading functions can make reading code much clearer/easier. This way functions that perform the same…

The C++ Do-While Loop

The Do-While loop is similar to the while loop. It is a conditional loop, just like the while loop, running the body of the loop while the condition is met. However, the big difference is that the do-while loop is a post-test loop. That means that the body runs at least once, and then there…

The C++ While Loop

A while loop says to perform a set of operations while a condition is true. It is known as a pre-test loop, because the condition is tested before the loop is run at all, meaning the body of the loop may never run. The general form for a while loop is: Notice that the loop…