I stumbled uppon this code and I am quite confused on how it compiles since one of the function from A refers to static B. Also what it's suppose to do.
where B is derived from A.
In A.h file
static A* instance();
in B.h
static B* instance() { return dynamic_cast<B*>(A::instance()); }
in B.cpp
A* A::instance()
{
static B s_instance;
return &s_instance;
}
Class definitions and such were omitted to lighten the code.