In C++, Is there any way/ procedure to know whether particular class has been inherited by other class?
Is it possible in C++
In C++, Is there any way/ procedure to know whether particular class has been inherited by other class?
Is it possible in C++
For example lets say you have the following two classes:
class A {};
class B : public A {};
If you ask if there is a way to know if A
have been inherited then no there is no such way.
If you ask if there is a way to know if B
inherits from another class (no matter what class it is) then no there is not.
The closest you can get is probably std::is_polymorphic
, which tells (compile time) if a class have virtual functions that can be inherited, or if a class have virtual functions that it have inherited. There is no functionality, compile time or run time, to tell if a class have been inherited, or what the base-classes of some class is.