Which of the following are never inherited?

public data members
constructor functions
void functions
overloaded + operators

The correct answer is: B. constructor functions

A constructor function is a special function that is called when an object is created. It is used to initialize the object’s data members. Constructor functions are not inherited because they are specific to the class in which they are defined.

Public data members are members of a class that are accessible to other classes. They are inherited by derived classes.

Void functions are functions that do not return a value. They are inherited by derived classes.

Overloaded + operators are operators that have been overloaded to perform different operations depending on the types of the operands. They are inherited by derived classes.

Here is a more detailed explanation of each option:

  • A. public data members

Public data members are members of a class that are accessible to other classes. They are inherited by derived classes. For example, if a class has a public data member called x, then any derived class will also have a public data member called x.

  • B. constructor functions

Constructor functions are special functions that are called when an object is created. They are used to initialize the object’s data members. Constructor functions are not inherited because they are specific to the class in which they are defined. For example, if a class has a constructor function called MyClass(), then any derived class will not have a constructor function called MyClass().

  • C. void functions

Void functions are functions that do not return a value. They are inherited by derived classes. For example, if a class has a void function called doSomething(), then any derived class will also have a void function called doSomething().

  • D. overloaded + operators

Overloaded + operators are operators that have been overloaded to perform different operations depending on the types of the operands. They are inherited by derived classes. For example, if a class has an overloaded + operator that can be used to add two integers, then any derived class will also have an overloaded + operator that can be used to add two integers.