200+ C++ Interview Questions To Ask When Hiring

Hiring can be a challenging task. Most difficult can be coming up with the proper questions to ask someone when attempting to conduct an interview. I've put together a long list of C++ interview questions which can hopefully give you a jump start in knowing what to ask. I'd recommend that if you are hiring with a team that you divide up these interview questions so that your team doesn't ask the same questions when not in the room together. One idea might be to have these questions be part of the Google Calendar invite (but not seen by the interviewing party). That way each person on the hiring staff knows who asked what question.

Hiring engineers is somewhat of an art form. I strongly suggest first conducting a virual interview, not utilizing the questions below. The questions below are better for in person working sessions where you and the applying engineer can sit together behind a whiteboard and articulate the answers better. That will provide you the most insight on the potential fit of the candidate. With these C++ interview questions, it should save you considerable time attempting to find the right question to ask during that session.

1. What is C++?
2. What are the advantages of C++?
3. What is the difference between C and C++?
4. What is the difference between reference and pointer?
5. What is a class?
6. What are the various OOPs concepts in C++?
7. What are the different types of polymorphism in C++?
8. Define namespace in C++.
9. Define token in C++.
10. Which operations are permitted on pointers?
11. Define 'std'.
12. Which programming language's unsatisfactory performance led to the discovery of C++?
13. How delete [] is different from delete?
14. What is the full form of STL in C++?
15. What is an object?
16. What are the C++ access specifiers?
17. What is Object Oriented Programming (OOP)?
18. What is the difference between an array and a list?
19. What is the difference between new() and malloc()?
20. What are the methods of exporting a function from a DLL?
21. Define friend function.
22. What is a virtual function?
23. What is a destructor?
24. What is an overflow error?
25. What is overloading?
26. What is function overriding?
27. What is virtual inheritance?
28. What is a constructor?
29. What is the purpose of the "delete" operator?
30. Explain this pointer?
31. What does Scope Resolution operator do?
32. What is the difference between delete and delete[]?
33. What is a pure virtual function?
34. What is the difference between struct and class?
35. What is a class template?
36. What is the difference between function overloading and operator overloading?
37. What will i and j equal after the code below is executed? Explain your answer.
int i = 5;
int j = i++;
38. Is it possible to have a recursive inline function?
39. What is a storage class?
40. Explain abstraction.
41. How should runtime errors be handled in C++?
42. When should a function throw an exception?
43. Where are setjmp and longjmp used in C++?
44. Are there any special rules about inlining?
45. Explain One-Definition Rule (ODR).
46. What are the advantages of using friend classes?
47. What is the use of default constructor?
48. Differentiate between class and structure.
49. Explain a container class.
50. What is a namespace?
51. Explain an explicit container.
52. Explain class invariant.
53. Differentiate between late binding and early binding. What are the advantages of early binding?
54. What is the difference between realloc() and free()?
55. How do you find out if a linked list has an end? (i.e. the list is not a cycle)
56. Write a function that can reverse a linked list.
57. What is the difference between declaration and definition?
58. How to check whether a linked list is circular.
59. What is a template?
60. What is RTTI?
61. What is encapsulation?
62. Explain the term ‘Polymorphism.’
63. What is a copy constructor and when is it called?
64. Which recursive sorting technique always makes recursive calls to sort subarrays that are about half size of the original array?
65. What is abstraction?
66. What is a scope resolution operator?
67. Explain the ISA and HASA class relationships. How would you implement each in a class design?
68. What is a mutable member?
69. Are there any new intrinsic (built-in) data types?
70. Define run-time type identification.
71. What is the output for the following program?
#define AREA(x)(3.14*x*x)
main()
{
float r1=6.25, r2=2.5, a;
a=AREA(r1);
printf(“\n Area of the circle is %f”, a);
a=AREA(r2);
printf(“\n Area of the circle is %f”, a);
}
72. What is an accessor?
73. When does a name clash occur?
74. What is a dangling pointer?
75. What do you mean by Stack unwinding?
76. What is chaining?
77. What is Quadratic Probing?
78. What is the use of using?
79. What is EOF?
80. What is a callback function?
81. What is the output for the following?
void main()
{
float j;
j=1000*1000;
printf(“%f”,j);
}
82. What is the output for the following?
void main()
{
int i;
for(i=1;i<4;i++)
switch(i)
case 1: printf(“%d”,i);break;
{
case 2: printf(“%d”,i);break;
case 3: printf(“%d”,i);break;
}
switch(i) case 4:printf(“%d”,i);
}
83. What is a nested class?
84. What is overflow error?
85. Define parameterized macros?
86. What is the use of exceptional handling?
87. What is a reference?
88. What is an orthogonal base class?
89. What are proxy objects?
90. What is a Null object?
91. What is an adaptor class or Wrapper class?
92. Differentiate between the message and method.
93. How do you declare an array of N pointers to function returning pointers to functions returning pointers to characters?
94. What is the output for the following?
void main()
{
unsigned i=1; /*unsigned char k=-1 =>k=255; */
signed j=-1; /* char k=-1 =>k=65535 */
/* unsigned or signed int k=-1 =>k=65535 */
if(i printf(“less);
else
if(i>j)
printf(“greater”);
else
if(i==j)
printf(“equal”);
}
95. What problems does the namespace feature solve?
96. When is a template a better solution than a base class?
97. When you should use multiple inheritances?
98. What is a conversion operator?
99. How many ways are there to initialize an int with a constant?
100. Explain the purpose of the keyword volatile.
101. Distinguish between shallow copy and deep copy.
102. What is the role of a static keyword on class member variable?
103. Explain static member function.
104. Explain the pointer – this.
105. What is the block scope variable in C++?
106. What is keyword auto for?
107. What is the remainder for 5.0%2?
108. What is the maximum length of an identifier?
109. What is ‘cin’?
110. What is ‘cout’?
111. What is the difference between actual and formal parameters?
112. Can we nest multi-line comments in a C++ code?
113. What is the order of objects destroyed in the memory?
114. If you want to share several functions or variables in several files maintaining the consistency how would you share it?
115. What do you mean by translation unit?
116. Describe linkages and types of linkages?
117. Keeping in mind the efficiency, which one between if-else and switch is more efficient?
118. What are structures and unions?
119. What is the difference between structures and unions?
120. What do you mean by enumerated data type?
121. How C functions prevent rework and therefore saves the programmers time as well as the length of the code?
122. Keyword mean in the declaration?
123. Can union be self-referenced?
124. Define pointers?
125. Which format specifier is used for printing a pointer value?
126. What is the use of 'auto' keyword?
127. What is the use of register keyword with the variables?
128. What do you mean by global variables?
129. What do you mean by static variables?
130. What do you mean by volatile variable?
131. What is the prototype of printf function?
132. Define macro.
133. What is the disadvantage of using a macro?
134. What is a void pointer?
135. What is an uninitialized pointer?
136. What do you know about near, far and huge pointer?
137. What are the characteristics of Class Members in C++?
138. Explain what is Loop function? What are different types of Loops?
139. Explain how functions are classified in C++?
140. Explain what are Access specifiers in C++ class? What are the types?
141. What is the C-style character string?
142. Mention what are the decision making statements in C++? Explain if statement with an example?
143. Explain what is upcasting in C++?
144. Write a program that will convert an integer pointer to an integer and vice-versa.
145. What is meant by const cast?
146. What is meant by forward referencing and when should it be used?
147. Write my own zero-argument manipulator that should work same as hex?
148. We all know that a const variable needs to be initialized at the time of declaration.
Then how come the program given below runs properly even when we have not initialized p?
#include
void main( )
{
const Char *p ;
p = "a const pointer" ;
cout << P ;
}
149. Refer to a name of class or function that is defined within a namespace?
150. Is it possible to provide default values while overloading a binary operator?
151. Carry out a conversion of one object of the user-defined type to another?
152. Write a code that allows creating only one instance of a class?
153. Write code to add functions, which would work as GET and PUT properties of a class?
154. Write a program that implements a date class containing day, month and year as data members. Implement assignment operator and copy constructor in this class.
155. When should I use unitbuf flag?
156. What are manipulators?
157. Differentiate between the manipulator and setf( ) function?
158. How to get the current position of the file pointer?
159. What are put and get pointers?
160. What does the nocreate and noreplace flag ensure when they are used for opening a file?
161. What is the limitation of cin while taking input for character array?
162. Mention the purpose of istream class?
163. Would the following code work?
#include
void main( )
{
ostream o ;
<< "dream. Then make it happen!";
}
164. Can we use this pointer inside a static member function?
165. What is strstream?
166. When the constructor of a base class calls a virtual function, why doesn't the override function of the derived class gets called?
167. Can i have a reference as a data member of a class? If yes, then how do i initialise it? 168. Why does the following code fail?
#include
#include
Class sample
{
Private :char *str ;
Public : sample ( char *s )
{
Strcpy ( str, s ) ;
}
~sample( )
{
Delete str ;
}
} ;
Void main( )
{
Sample s1 ( "abc" ) ;
}
169. Assert( ) macro...
170. Why is that unsafe to deallocate the memory using free( ) if it has been allocated using new?
171. Can we distribute function templates and class templates in object libraries?
172. Differentiate between an inspector and a mutator?
173. Can a user-defined object be declared as a static data member of another class?
174. What is a forward referencing and when should it be used?
175. What is virtual multiple inheritances?
176. Can we use this pointer in a class specific, an operator-overloading function for a new operator?
177. How to allocate memory dynamically for a reference?
178. Write code to make an object work like a 2-d array?
179. What are formatting flags in ios class? 180. What is the purpose of ios::basefield in the following statement?
cout.setf ( ios::hex, ios::basefield );
181. Can we get the value of ios format flags?
182. Is there any function that can skip a certain number of characters present in the input stream?
183. When should overload new operator on a global basis or a class basis?
184. How to give an alternate name to a namespace?
185. Define a pointer to a data member of the type pointer to pointer?
186. Using a smart pointer can we iterate through a container?
187. Is it possible for the objects to read and write themselves?
188. Why is it necessary to use a reference in the argument to the copy constructor?
189. What is a modifier in C++?
190. Differentiate between a template class and class template in C++?
191. What is an incomplete type in C++?
192. What are the conditions that have to be met for a condition to be an invariant of the class?
193. What is a node class in C++?
194. What is Boyce Codd Normal Form?
195. Write a struct Time where integer m, h, s are its members
196. How do you traverse a btree in backward in-order?
197. In the derived class, which data member of the base class are visible?
198. Write a program that ask for user input from 5 to 9 then calculate the average?
199. Write a short code using C++ to print out all odd number from 1 to 100 using a for loop
200. What is public, protected, private in C++?
201. write a function that swaps the values of two integers, using int* as the argument type?
202. What is the difference between an array and a list?
203. Does C++ support multilevel and multiple inheritance?
204. What is the difference between an "assignment operator" and a "copy constructor"?
205. What is the difference between mutex and binary semaphore?
206. What is an explicit constructor?
207. Explain the scope resolution operator?

Want higher salary?

Our comprehensive free guide on increasing your salary through new or existing employment has finally dropped. Get it here.

     

    Share

    Help us by spreading the word