In C++, a class containing only pure virtual functions is commonly used to represent which concept?
class Printable
{
public:
virtual void print() = 0;
virtual void save() = 0;
};
Options
-
A.
Interface-like abstraction
-
B.
Local variable
-
C.
Preprocessor macro
-
D.
More than one of the above
-
E.
None of the above
Correct Answer (Detailed Explanation is Below)
A.
Interface-like abstraction
Detailed Explanation
Answer: (A) Interface-like abstraction
C++ does not have a separate interface keyword like some other languages.
However, a class containing pure virtual functions can be used to define an interface-like abstraction.
Derived classes are expected to provide implementations for those functions.
This allows a program to define what operations a class should provide without specifying all implementation details in the base class.