Google News
logo
CPP Interview Questions
Method overloading is having functions with the same name but different argument lists. This is a form of compile-time polymorphism.
 
Method overriding comes into picture when we rewrite the method that is derived from a base class. Method overriding is used while dealing with run-time polymorphism or virtual functions.
“ISA” relationship usually exhibits inheritance as it implies that a class “ISA” specialized version of another class. For Example, An employee ISA person. That means an Employee class is inherited from the Person class.
 
Contrary to “ISA”, “HASA” relationship depicts that an entity may have another entity as its member or a class has another object embedded inside it.
 
So taking the same example of an Employee class, the way in which we associate the Salary class with the employee is not by inheriting it but by including or containing the Salary object inside the Employee class. “HASA” relationship is best exhibited by containment or aggregation.
* An internal iterator is implemented by the member functions of the class which has the iteration logic.
* An external iterator is implemented by a separate class which can be attached to the object which has iteration logic.
* The advantage of external iterator is that, many iterators can be made active simultaneously on the existing or same object.
1. Const : This variable means that if the memory is initialised once, it should not be altered by a program.

2. Volatile : This variable means that the value in the memory location can be altered even though nothing in the program code modifies the contents.

3. Mutable : This variable means that a particular member of a structure or class can be altered even if a particular structure variable, class or class member function is constant.
Deep copy : It involves using the contents of one object to create another instance of the same class. Here, the two objects may contain the same information but the target object will have its own buffers and resources. The destruction of either object will not affect the remaining objects.
 
Shallow copy : It involves copying the contents of one object into another instance of the same class. This creates a mirror image. The two objects share the same externally contained contents of the other object to be unpredictable.This happens because of the straight copying of references and pointers.
(a) Stack Area : This part of memory is used to store formal parameters, local variables, return addresses of function call etc.

(b) Program Code Area : This part of memory is used to store the object code of the program.

(c) Global Variable Section : This part of memory is used to store global variables defined in the program.

(d) Heap Area or Free Storage Pool : It consists of unallocated memory locations which are allocated dynamically during program execution using new operator.
Finding the location of a given element in a given data structure is called searching.
 
There are two types of search :
 
1. Linear Search : In this, the element to be searched is compared one by one with each element of given list, starting with first element. The process of comparisons remain continue until the element is not found or list gets exhausted.
 
2. Binary Search : It is another technique of searching an element in a given list in minimum possible comparisons. But for applying binary search on a list, there are two pre-conditions :

     (i)  The elements of list must be arranged either in ascending or descending order.
     (ii) The list must be of finite size and should be in form of linear array.
The Standard template library is used as a container to the templates which have been approved by the ANSI. It includes the standard C++ specification. It helps to construct programming in object oriented manner. It allows the use of pre-defined libraries for generic programming model. It allows faster execution of the programs and allow the user to use functions without even writing them.
We organize our C++ programs into different source files (.cpp, .cxx etc). When you consider a source file, at the preprocessing stage, some extra content may get added to the source code ( for example, the contents of header files included) and some content may get removed ( for example, the part of the code in the #ifdef of #ifndef block which resolve to false/0 based on the symbols defined). This effective content is called a translation unit. 
 
* Contents of source file
* Plus contents of files included directly or indirectly
* Minus source code lines ignored by any conditional pre processing directives ( the lines ignored by #ifdef,#ifndef etc)
The goto statement is used to alter the program execution sequence by transferring the control to some other part of the program.
 
The unconditional goto statement is used just to transfer the control from one part of the program to the other part without checking any condition. Normally, a good programmer will not prefer to use the unconditional goto statement in his program as it may lead to a very complicated problem like a never ending process.