Posts

Importance of Unit Testing

Image
Importance of Unit Testing   In this post, we will discuss about Unit Testing. The below topics will be covered Brief Introduction to Unit Testing Advantages of Unit Testing Limitations of Unit Testing Brief Introduction to Unit Testing Nowadays Unit Testing is essential in the Software Development process.  Unit Testing ensures the quality of software deliverables.  During recruitment all leading Organizations keep Unit Testing as the primary skill set in their job description. 1.1 Types of Unit Testing Unit Testing is categorized as below Manual Unit testing Automation of Unit testing 1.1.1 Manual Unit Testing Developers will write unit tests specific to the module under development and document them. During development, test cases will be executed before committing the source code for that module to the repository. Manual Unit tests will be executed on the target platform on which the final released Software will run.  Developers run the software under d...

C++ Constant Expressions Vs Macros

Image
C++ Constant Expressions Vs Macros   In this post, we will discuss C++ Constant Expressions (   const expr) and how they replace traditional   Macros(#define) . Macros in C/C++ Macro is a Preprocessor directive in C/C++ used to define expressions with names.  Before compilation, the Preprocessor will search for the name in the entire code and replace it with the expression. Below is an example of how to define a macro identifier with a value #include<stdio.h> //here are defining a macro #define PI 3.14 int main () { int radius = 5 ; /* * In the below code Preprocess replace PI with 3.14 before compilation */ int area_of_circle = PI*radius*radius; printf( "Area is : %d\n" ,area_of_circle); int perimeter = 2 *PI*radius; printf( "Perimeter is : %d\n\n" ,perimeter); return 0 ; } Below is an example of how to define a macro expression  #include<stdio.h> //her are defining a macr...

C++ Virtual Functions uses and Limitations

Image
 What is a Virtual Function in C++? C++ Virtual function is a Class member function used with Inheritance in  C++ to achieve Runtime Polymorphism . We know Polymorphism means functions with the same name but different arguments. In  Runtime Polymorphism Parent and Child classes have functions with the same name and also the same arguments which is called Overriding . Base class functions are prepended with the keyword virtual so that they can be overridden in child classes to add more functionality.   The difference between virtual and non-virtual is  Call to non-virtual functions resolved at compile time based on the type of Object pointer/Reference on which it is called. Call to virtual functions resolved at runtime based on the actual object to which the pointer/reference is pointing. 1 Runtime Polymorphism Before going to Virtual Function,  let's discuss more about the Runtime Polymorphism with some example Runtime Polymorphism exists because in C+...