class Animal {};
class Mammals : public Animal {};
class Birds : public Animal {};
class Aquatic : public Animal {};
class Fox: public Mammals {};
class Cat: public Mammals {};
class Hawk: public Birds {};
class Duck: public Birds {};
class Fish: public Aquatic {};
class Crab: public Aquatic {};
How do I know if a class is an immediate subclass or a distance subclass of another? For example,
Hawk hawk;
how do I check that "hawk" is a bird?
What if Hawk becomes the parent to other classes? For example,
#include <iostream>
#include <type_traits>
class Animal {};
class Birds : public Animal {};
class Hawk: public Birds {};
class RedTailedHawk : public Hawk {};
int main()
{
std::cout << std::boolalpha;
std::cout << std::is_base_of<Birds, RedTailedHawk>::value << '\n'; // true
}