Both a structure and a class provides a way to create a customized data type which can be used further to create instances. C++ expands the role of structure to create a class. The Structure and class, are almost similar in all respect except the significant one difference that, structure by default have all its member as “public”, and class by default have all its member “private”. Furthermore, polymorphism and inheritance are not supported by the structure, but classes support polymorphism … [Read more...]
Difference Between Array and Pointer
Array and pointer both are programming elements. An array is a data structure that holds variables of the same data type. On the other hand, the pointer is a kind of variable that holds the address of another variable which has the same data type as of pointer variable. We can even use a pointer to access the array elements. Accessing the whole array using pointer arithmetic, makes the accessing faster. While implementing an array a fixed memory size is allocated to array elements. … [Read more...]
Difference Between for and while loop
In C++ and Java, the iteration statements, for loop, while loop and do-while loop, allow the set of instructions to be repeatedly executed, till the condition is true and terminates as soon as the condition becomes false. Conditions in iteration statements may be predefined as in for loop or open-ended as in while loop. There are several 'for' loop variations in C++ are implied to increase its applicability, power and flexibility. For example, the for loop allows us to use more than one … [Read more...]
Difference Between while and do-while Loop
Iteration statements allow the set of instructions to execute repeatedly till the condition doesn't turn out false. The Iteration statements in C++ and Java are, for loop, while loop and do while loop. These statements are commonly called loops. Here, the main difference between a while loop and do while loop is that while loop check condition before iteration of the loop. On the other hand, the do-while loop verifies the condition after the execution of the statements inside the … [Read more...]
Difference Between Virtual and Pure Virtual Function
The virtual function and pure virtual function both are the concepts of run time polymorphism. The main difference between ‘virtual function’ and ‘pure virtual function’ is that ‘virtual function’ has its definition in the base class and also the inheriting derived classes redefine it. The pure virtual function has no definition in the base class, and all the inheriting derived classes has to redefine it. However, the virtual function is also called as dynamic dispatch and run-time dispatch, … [Read more...]
Difference Between Call By Value and Call by Reference
Call by value and call by reference are two different techniques to call a function or a method in a program. The call-by-value technique only passes the values of the variables. On the other hand, call by reference technique passes addresses of the variables. If you are passing arguments to a function using the 'call by value' technique, then changes to the variables inside the function won't affect the original values of those variables. If you pass arguments to a function using the … [Read more...]
Difference Between One-Dimensional (1D) and Two-Dimensional (2D) Array
An array is a collection of variables that are of similar data types and are alluded by a common name. The main topic of our discussion is the difference between One-dimension and Two-Dimension array. A one-dimensional array is a list of variables with the same data type, whereas the two-Dimensional array is ‘array of arrays’ having similar data types. A specific element in an array is accessed by a particular index of that array. Arrays in Java work differently as compared to C++. C++ do not … [Read more...]
Difference Between break and continue
Both “break” and “continue” are the ‘jump’ statements, that transfer control of the program to another part of the program. The main difference between break and continue is that break is used for immediate termination of loop. On the other hand, 'continue' terminate the current iteration and resumes the control to the next iteration of the loop. The break statement is primarily used as the exit statement, which helps in escaping from the current block or loop. Conversely, the continue … [Read more...]
Difference Between Type Casting and Type Conversion
The basic difference between type conversion and type casting, i.e. type conversion is made “automatically” by compiler whereas, type casting is to be “explicitly done” by the programmer. The two terms “type casting” and “type conversion” occur when there is a need to convert one data type to another. When the two types are compatible with each other, then the conversion of one type to other is done automatically by the compiler. Let’s discuss the difference both type casting and conversion … [Read more...]
Difference Between Static and Dynamic Binding
Binding association of a 'function definition' to a 'function call' or an association of a 'value' to a 'variable', is called 'binding'. During compilation, every 'function definition' is given a memory address; as soon as function calling is done, control of program execution moves to that memory address and get the function code stored at that location executed, this is Binding of 'function call' to 'function definition'. Binding can be classified as 'static binding' and 'dynamic … [Read more...]