std::is_base_of template in C++ with Examples
The std::is_base_of template of C++ STL is present in the <type_traits> header file. The std::is_base_of template of C++ STL is used to check whether class Base is the base class of Derived class or not. It return the boolean value true or false on the basis of above condition.
template <class Base, class Derived> struct is_base_of;
Parameters: It accepts the below two classes as a parameters:
- class A(as a Base class): It represents the base class.
- class B(as a Derived class): It represents the derived class.
Return Value: This template returns a boolean variable as shown below:
- True: If the Base class(class A) is the parent of the Derived class(class B).
- False: If the Base class(class A) is not the parent of the Derived class(class B).
Below is the program to illustrates the std::is_base_of template in C/C++:
A is base class of B: true B is base class of A: false C is base class of B: false C is base class of C: true
My Personal Notes arrow_drop_up
Please Login to comment...