C++ Interview Questions and Answers

What is function overloading?

Function overloading or Function polymorphism is the ability to write more than one function with the same name, but the number or type of the parameters is different.


What is the difference between function overloading and overriding?

Overloading of Function called when more than one method created with the same name, but with a different signature (number and type of its Parameters). While in function overriding, method created in a derived class with the same name as a method in the base class and the same signature (number and type of its Parameters).


What is operator overloading?

Operator overloading is a mechanism that help to perform Operator operation on User defined data types like they operate on built-in data types, such as addition (+) and multiplication (*).


What is virtual function?

Runtime Polymorphism or dynamic binding mechanism is supported the use of virtual functions whereas pointers of base classes can keep derived class objects. Thus,
<base class>* baseObj = new <derived class>;

When derived class override base class virtual function then the override function call depend on contents (object pointed) of base class pointer that resolved at run time.


What is pure virtual functions?

A pure virtual member function is made by initializing it with zero in the base class and those must be override in derived classes.

virtual void speak () = 0;

What do you mean by inline function?

On calling the function, execution of the program jumps to calling function instructions, and when the function returns, execution jumps back to the next line in the calling function.It is some performance overhead in jumping in and out of functions.
When a function is declared with the keyword inline, the compiler does not create a real function: it copies the code from the inline function directly into the calling function. No jump is made; it is just as written the statements of the function right into the calling function.

Latest Updates