Loading...

C++ Programming Interview Questions

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

C++ Interview Questions Set-7

Commonly Asked C++ Programming Interview Questions | Set 7


61. Define Block scope variable?
Ans: A Block scope variable is the one that is specified as a block using the C++ that can be declared anywhere within the block.


62. What are the functions of the scope resolution operator?
Ans: The functions of the scope resolution operator include the following.

  1. It helps in resolving the scope of various global variables.
  2. It helps in associating the function with the class when it is defined outside the class.


63. What is the function of the keyword "Auto"?
Ans: The keyword “Auto” is used by default for various local variables to make function work automatically.


64. What are character constants in C++?
Ans: Character constant are members of the character set in which a program is written which is surrounded by single quotation marks (‘).


65. What do you mean by scope resolution operator?
Ans: Scope resolution operator is represented as ::.
This operator can be used to associate the function definition to a particular class, when a class member is defined outside the class?


66. Can we use malloc() function of C language to allocate dynamic memory in C++?
Ans: Yes, as C is the subset of C++, we can all the functions of C in C++ too.


67. What is a Copy Constructor?
Ans: A copy constructor is the constructor which takes same class object as the parameter. It gets automatically invoked as soon as the object is initialized with another object of the same class.
A copy constructor has the following general function prototype: ClassName (const ClassName &old_obj){ }


68. Can a program be compiled without main() function in C++?
Ans: Yes, it can be compiled. But cannot be executed, as the execution requires main() function definition.


69. Does an abstract class in C++ need to hold all pure virtual functions?
Ans: No, a class having at least one pure virtual function is abstract class too.


70. What is the order of objects destroyed in the memory?
Ans: The objects are destroyed in the reverse order of their creation.


- Related Topics