Inheritance: Function that returns self type?
You can use CRTP, the curiously recurring template pattern:
template<class Derived>
class A {
public:
Derived* Hello() {
return static_cast<Derived*>(this);
}
};
class B : public A<B> {
public:
B* World() {
return this;
}
};
int main() {
B test;
test.World()->Hello();
test.Hello()->World();
}