C++C++11C++14C++17Learn C++

Learn to Use Constant References in C++ Functions

When we call a function with parameters taken by value, it copies the values to be made. This is a relatively inexpensive operation for fundamental types such as int, float, etc. If the parameter is composed of a large compound type, this may result in a certain overhead. For example, let’s consider this following function to combine name, mid name, and surname. string fullname (string…
Read more
C++C++11C++14C++17Introduction to C++Learn C++

Learn About Function Declaration and Definition in C++

In C and C++ programming language there are two parts of a function, Declaration, and Definition. Function Declarationis the combination of the return type of function, function’s name, and parameters in parenthesis.Function Definitionis the body of the function includes statements and other functions. In general use, they are defined together as below, myfunction() // this…
Read more
C++C++11C++14C++17Introduction to C++Learn C++

Learn to Use While and Do-While Loops in C++

While loops allow you to repeat a block of code as long as your specified condition is reached. Loops are used very offend in programming because they save time, reduce errors, and they make code more readable. 1. The While Loop In the mechanism of the while statement, the condition is evaluated and if it returns true then the code block inside the while loop will be executed, this will…
Read more