C++ Interview Questions & Answers part 1

Q: – What is the advantage of function overloading according to users point of view?

We know that function name is same. But each time we are writing code for each function. In this case it is advantageous than normal function.

Q: – Why would you ever use default values when you can overload a function?

It is easier to maintain one function than two, and it is often easier to understand a function with default parameters than to study the bodies of two functions. Furthermore, updating one of the functions and neglecting to update the second is a common source of bugs.

C++ used for:
C++ is a powerful general-purpose programming language. It can be used to create small programs or large applications

Q: – Given the problems with overloaded functions, why not always use default values instead?

Overloaded functions supply capabilities not available with default variables, such as varying the list of parameters by type rather than just by number.

Q: – What is difference between visual c++ & ANSI c++ ?

Visual C++ is probably the most popular favored compiler, because of it's history of quality and stablity.But in ANSI C++ is a less popular, but is a much more powerful and robust compiler. The IDE is also a lot more powerful than MSVC.


Q: – Can a derived class make a public base function private?


Q: – What Is an Array?

An array is a collection of data storage locations, each of which holds the same type of data. Each storage location is called an element of the array.

Q: – What is in an uninitialized array element?

Whatever happens to be in memory at a given time. The results of using this member without assigning a value are unpredictable.

Q: – When writing a class constructor, how do you decide what to put in the initialization and what to put in the body of the constructor?

A simple rule of thumb is to do as much as possible in the initialization phase—that is, initialize all member variables there. Some things, like computations and print statements, must be in the body of the constructor.

Q: – What is RTTI?

RTTI bassicaly Run Time Type Information. It Certain language features to work a limited amount of information about types is required at runtime. This is the Run Time Type Information or RTTI.

Submitted By:-Ankur Goyal            Email-ID: – goyal.ankur30@yahoo.in