C++ Questions and Answers - 1

Question: 1

How is polymorphism achieved?

Polymorphism is achieved through function overloading and operator overloading.

Question: 2

What is integral promotion of data?

When C++ did not find the exact match of a function call, the compiler will promote data to find the nearest match.

For example, char type can be promoted to integer/float/double.

Integral promotions are purely compiler oriented.

Question: 3

What is operator overloading?

The mechanism of giving special meaning to an operator is called as operator overloading.

Question: 4

List out any four operators that can be overloaded?

+

++

--

*

Question: 5

Write any four rules for function overloading.

Each overloaded function must differ either by the number of its formal parameters or their data types.

The return type of overloaded functions may or may not be the same data type.

The default arguments of overloaded functions are not considered by the C++ compiler as part of the parameter list.

Do not use the same function name for two unrelated functions.

Related Questions