#include <iostream>
using namespace std;
template< typename LeafT>
class ATree {
public:
virtual ATree< LeafT> * branch() = 0;
};
template< typename LeafT, typename Self>
class Tree : public ATree< LeafT> {
public:
Self * branch() {}
};
template< typename LeafT>
class C : public Tree< LeafT, C< LeafT> > {};
int main() {
C< int> t;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKICB0ZW1wbGF0ZTwgdHlwZW5hbWUgTGVhZlQ+CiAgICBjbGFzcyBBVHJlZSB7CiAgICBwdWJsaWM6CiAgICAgICAgdmlydHVhbCAgQVRyZWU8IExlYWZUPiAqIGJyYW5jaCgpID0gMDsKICAgIH07CgogIHRlbXBsYXRlPCB0eXBlbmFtZSBMZWFmVCwgdHlwZW5hbWUgU2VsZj4KICAgIGNsYXNzIFRyZWUgOiBwdWJsaWMgQVRyZWU8IExlYWZUPiB7CiAgICBwdWJsaWM6CiAgICAgICAgU2VsZiAqIGJyYW5jaCgpIHt9CiAgICB9OwoKICB0ZW1wbGF0ZTwgdHlwZW5hbWUgTGVhZlQ+CiAgICBjbGFzcyBDIDogcHVibGljIFRyZWU8IExlYWZULCBDPCBMZWFmVD4gPiB7fTsKCmludCBtYWluKCkgewoJQzwgaW50PiB0OwoKCXJldHVybiAwOwp9
prog.cpp: In instantiation of 'class Tree<int, C<int> >':
prog.cpp:17:11: required from 'class C<int>'
prog.cpp:20:10: required from here
prog.cpp:13:16: error: invalid covariant return type for 'Self* Tree<LeafT, Self>::branch() [with LeafT = int; Self = C<int>]'
Self * branch() {}
^
prog.cpp:7:34: error: overriding 'ATree<LeafT>* ATree<LeafT>::branch() [with LeafT = int]'
virtual ATree< LeafT> * branch() = 0;
^