What is the impact of a function having a default argument? 

  • It allows function overloading. 
  • It allows multiple return types for the function. 
  • It can be called with fewer arguments than defined. 
  • It enhances runtime performance.
When a function has a default argument, it can be called with fewer arguments than it defines. The compiler will use the default value for any arguments not provided by the caller. This feature aids in providing flexibility while calling functions but doesn't directly enhance runtime performance.

Imagine you are developing an e-commerce system where different types of users (Admin, Buyer, and Seller) exist. Which inheritance model might be beneficial to maintain, expand, and utilize polymorphic behavior? 

  • Single Inheritance 
  • Multiple Inheritance 
  • Hierarchical Inheritance 
  • Hybrid Inheritance
Hierarchical inheritance is where a single class serves as a base class (superclass) for more than one derived class (subclass). In this scenario, the common attributes and methods of users can be part of the base class, while unique functionalities for Admin, Buyer, and Seller can be defined in their respective derived classes.

When is a copy constructor called in a C++ program? 

  • When an object is returned by value from a function. 
  • When we assign values from one object to another without the use of pointers. 
  • When an array of objects is created. 
  • When a function is called by value.
A copy constructor in C++ is called in several scenarios: 1) when an object is passed (by value) to a function, 2) when an object is returned (by value) from a function, 3) when an object is constructed based on another object of the same class, and 4) during the initialization of an object from another.

The enum class introduces _______ scope to prevent enumerators from polluting the namespace. 

  • global 
  • restricted 
  • local 
  • strong
The enum class introduces "strong" scoping. This ensures that the enumerator names are not directly accessible without the name of the enumeration, thus preventing name clashes and polluting the global namespace.

To find the first mismatching elements of two ranges in C++ STL, use the _______ algorithm. 

  • find 
  • mismatch 
  • search 
  • differentiate
The mismatch algorithm in C++ STL is used to compare two ranges and returns a pair of iterators pointing to the first position where the two ranges differ.

The _______ keyword is used to explicitly instantiate a template. 

  • extern 
  • instantiate 
  • explicit 
  • using
The "extern" keyword can be used to explicitly instantiate a template. While templates are usually instantiated implicitly when they are used, in certain scenarios, developers might want to instantiate a template explicitly to ensure that instantiation happens in a particular translation unit, and "extern" facilitates this.

How does the continue statement affect the execution of a nested loop structure? 

  • It jumps to the next iteration of the innermost loop. 
  • It jumps to the next iteration of the outermost loop. 
  • It stops the entire program execution. 
  • It restarts all loops from the beginning.
The continue statement causes the current iteration of the loop to terminate, and the control jumps to the next iteration of the innermost loop that contains the continue. It won't affect any outer loops in the nested structure unless it's placed in the outer loop itself.

What will happen if the break statement is used outside any loop or switch statement? 

  • The program will crash. 
  • It will skip the next statement. 
  • It results in a compilation error. 
  • It breaks out of the main function.
Using the break statement outside of a loop or switch will result in a compilation error. The break statement is meant to terminate the nearest enclosing loop or switch where it appears. If it's placed elsewhere, it won't make logical sense to the compiler.

The _______ keyword is used to specify a class should not be instantiated directly, but only used as a base class. 

  • virtual 
  • abstract 
  • sealed 
  • interface
In C++, an "abstract" class is one that cannot be instantiated directly. It is intended to be used as a base class from which other classes are derived, and it may have one or more pure virtual functions.

A function in your codebase is exhibiting unexpected behavior because it is being passed an argument of an incorrect type, but the compiler is not generating an error. What might be a potential reason for this, and how could it be resolved? 

  • The compiler is outdated. 
  • Function overloading is causing ambiguity. 
  • Argument type has an implicit conversion to the expected type. 
  • There's an error in the compiler settings.
Implicit type conversions in C++ can sometimes lead to unexpected behavior, especially if a function argument undergoes an unintended conversion. This can be resolved by either making the type conversion explicit or by using strong type checks and avoiding implicit conversions.