Loading...

C++ Programming Interview Questions

This article is mainly focused on the most repeatedly asked and the latest updated questions.

C++ Interview Questions Set-5

Commonly Asked C++ Programming Interview Questions | Set 5


41. What is iostream in C++?
Ans: It is a header file that includes basic objects such as cin, cout, cerr, clog.


42. How to give space in C++?
Ans: In C++ programming, the space can be given using the following code. cout << ” ” ;


43. How is function overloading different from operator overloading?
Ans: Function overloading allows two or more functions with different type and number of parameters to have the same name. On the other hand, operator overloading allows for redefining the way an operator works for user-defined types.


44. Is it possible for a C++ program to be compiled without the main() function?
Ans: Yes, it is possible. However, as the main() function is essential for the execution of the program, the program will stop after compiling and will not execute.


45. Define basic type of variable used for a different condition in C++?
Ans: The variable used for a different condition in C++ are:

  • Bool: Variable to store boolean values (true or false)
  • Char: Variable to store character types
  • int : Variable with integral values
  • float and double: Types of variables with large and floating point values


46. What differences separate structure from a class in C++?
Ans: There are two important distinctions between a class and a structure in C++. These are:

  1. When deriving a structure from a class or some other structure, the default access specifier for the base class or structure is public. On the contrary, default access specifier is private when deriving a class.
  2. While the members of a structure are public by default, the members of a class are private by default


47. Explain what is Loop function? What are different types of Loops?
Ans: In any programming language, to execute a set of statements repeatedly until a particular condition is satisfied Loop function is used. The loop statement is kept under the curly braces { } referred as Loop body.
In C++ language, three types of loops are used

  • While loop
  • For loop
  • Do-while loop


48. What is iterator in C++?
Ans: Any object which has an ability to iterate through elements of the range it has been pointing to is called iterator.


49. What is :: in C++?
Ans: :: is called a scope resolution operator which is used to access global variables with the same name as of local variables, for defining functions outside the class, for accessing static variables, and for referring to a class inside of another class.


50. What does a Static member in C++ mean?
Ans: Denoted by the static keyword, a static member is allocated storage, in the static storage area, only once during the program lifetime. Some important facts pertaining to the static members are:

  1. When deriving a structure from a class or some other structure, the default access specifier for the base class or structure is public. On the contrary, default access specifier is private when deriving a class.
  2. While the members of a structure are public by default, the members of a class are private by default


- Related Topics