C plus plus Interview Questions & Answers

Showing 10 of 92 questions | Page 4

Technical interview questions and answers play a major role in C++ Interviews because C++ is widely used in system programming, game development, competitive coding, and performance-critical applications. Companies expect candidates to know OOP concepts, classes, inheritance, polymorphism, references, memory management, STL, and exception handling. These questions often appear in campus placements and software interviews conducted by TCS, Wipro, Infosys, Cognizant, and Capgemini. This guide covers frequently asked C++ interview questions with simple explanations that help freshers and job seekers strengthen their programming foundation. Preparing these questions will help you perform well in coding tests, technical rounds, and real-time problem-solving interviews.

Showing 10 of 92 questions

31. What is a parameterized type?

A template is a parameterized construct or type containing generic code that can use or manipulate any type. It is called parameterized because an actual type is a parameter of the code body. Polymorphism may be achieved through parameterized types. This type of polymorphism is called parameteric polymorphism. Parameteric polymorphism is the mechanism by which the same code is used on different types passed as parameters.

32. Differentiate between a deep copy and a shallow copy?

Deep copy involves using the contents of one object to create another instance of the same class. In a deep copy, the two objects may contain ht same information but the target object will have its own buffers and resources. the destruction of either object will not affect the remaining object. The overloaded assignment operator would create a deep copy of objects. Shallow copy involves copying the contents of one object into another instance of the same class thus creating a mirror image.

33. What is an opaque pointer?

A pointer is said to be opaque if the definition of the type to which it points to is not included in the current translation unit. A translation unit is the result of merging an implementation file with all its headers and header files.

34. What is a smart pointer?

A smart pointer is an object that acts, looks and feels like a normal pointer but offers more functionality. In C++, smart pointers are implemented as template classes that encapsulate a pointer and override standard pointer operators. They have a number of advantages over regular pointers. They are guaranteed to be initialized as either null pointers or pointers to a heap object. Indirection through a null pointer is checked. No delete is ever necessary. Objects are automatically freed whe

35. What is reflexive association?

The 'is-a' is called a reflexive association because the reflexive association permits classes to bear the is-a association not only with their super-classes but also with themselves. It differs from a 'specializes-from' as 'specializes-from' is usually used to describe the association between a super-class and a sub-class.

36. What is slicing?

Slicing means that the data added by a subclass are discarded when an object of the subclass is passed or returned by value or from a function expecting a base class object.

37. What is name mangling?

Name mangling is the process through which your c++ compilers give each function in your program a unique name. In C++, all programs have at-least a few functions with the same name. Name mangling is a concession to the fact that linker always insists on all function names being unique.

38. What are proxy objects?

Objects that points to other objects are called proxy objects or surrogates. Its an object that provides the same interface as its server object but does not have any functionality. During a method invocation, it routes data to the true server object and sends back the return value to the object.

39. Differentiate between declaration and definition in C++.

A declaration introduces a name into the program; a definition provides a unique description of an entity (e.g. type, instance, and function). Declarations can be repeated in a given scope, it introduces a name in a given scope. There must be exactly one definition of every object, function or class used in a C++ program. A declaration is a definition unless: Ø it declares a function without specifying its body, Ø it contains an extern specifier and no initializer or function body, Ø it i

40. What is cloning?

An object can carry out copying in two ways i.e. it can set itself to be a copy of another object, or it can return a copy of itself. The latter process is called cloning.
Questions and Answers for Competitive Exams Various Entrance Test