C++ Technical Interview Question on polymorphism in oops Write a complete class stating function overriding feature in C++ Show the function call in main program. Explain the concept of function overriding. Take example of drawing multiple shapes e.g. circle and rectangle etc. Interviewer Intent: You know the concept and syntax of function overriding in C++ … Read more A good interview question based on a C++ polymorphism in oops
Answer includes how to delete array of objects in C++ created dynamically with C++ code example with proof. In other words, delete array of pointers to objects in c++. Interview Question: Write C++ code to create an array of objects using new keyword and delete these objects. Also, proof that all the objects are deleted … Read more How to delete array of objects in C++? Proof by C++ code for proper deletion
Answer includes multiple solutions to stop or prevent class inheritance in C++ with condition that object creation of the class should be allowed with C++ program example and explanation. Interview Question: I want to stop a class to be inherited and allow to create an object of the class. Design a solution for this problem … Read more How to stop class inheritance in C++ with condition that object creation should be allowed
Answer includes use and advantage of this pointer in C++ programming with multiple scenarios where THIS pointer is used. Sceranio-1: Internal use of this pointer. Wherever an object calls a class member function then compiler internally pass a THIS pointer to member function internally. For example, in below class, we have a Set model member … Read more What is Advantage and Use of THIS pointer in C++ – Scenarios?
We cannot use THIS pointer in static function of a class in C++ program. Reason: Whenever we call a class non-static member function using class object then THIS pointer is also passed to the function as a parameter internally and this is why a non-static member function of a class know that on which class … Read more Can we use THIS Pointer in static function – Reason in C++?
Interview Question: A class is having private data members and that is by design and expected. Question is, if we write C++ public access specifier instead of private for that data members then what issue we can face in a C++ program? If you want to know access specifiers in C++ programming, read another interview … Read more C++ Public access specifier instead of Private – What is bad?
Answer: Use of public private and protected access specifiers in C++ is to control the access/visibility of member data and functions out of a class. It all depends upon requirement when we design a class, what access level to fields and member functions, we want to provide in a class with the use of public private … Read more Use of Public Private and Protected access specifiers in C++?
Interview Question on memory allocation failure in C++: when you do memory allocation using new in C++ and it fails then what are issues? In another words, when you allocate memory on heap using new operator, how do you handle memory allocation using new in C++ failure? What is issue when you don’t handle it? … Read more What if memory allocation using new fails in C++ how to handle
When to use RTTI (Run Time Type Information) dynamic_cast in C++ is frequently asked c++ technical interview question. Answer to this question will cover multiple scenarios where we can use dynamic_cast in C++ program. Answer: Scenarios – Use of Dynamic_cast in C++ program: Situation 1- When we need to call a specialized member function of … Read more When to use RTTI – Dynamic_cast in C++
What is smart pointer and implementation of Smart pointer in C++. This simple smart pointer implementation in C++ is asked in technical interview to know if we know the concept of smart pointer and able to implement it. Answer: Smart pointers are a pointers that get de-allocated by itself, when it goes out of scope and … Read more Writing Smart Pointer in C++ for a Specific Class