template<class T>
class SomeTemplate
{
public:
SomeTemplate(T* p) { pData = p; }
T* getPointer() { return pData; }
template<class S>
SomeTemplate(SomeTemplate<S> s)
{
pData = s.getPointer();
}
private:
T* pData;
};
class A {};
class B : public A {};
int main()
{
SomeTemplate<B> b(new B());
SomeTemplate<A> a(b);
return 0;
}
dGVtcGxhdGU8Y2xhc3MgVD4KY2xhc3MgU29tZVRlbXBsYXRlCnsKcHVibGljOgogICBTb21lVGVtcGxhdGUoVCogcCkgeyBwRGF0YSA9IHA7IH0KICAgVCogZ2V0UG9pbnRlcigpIHsgcmV0dXJuIHBEYXRhOyB9CiAgIHRlbXBsYXRlPGNsYXNzIFM+CiAgIFNvbWVUZW1wbGF0ZShTb21lVGVtcGxhdGU8Uz4gcykKICAgewogICAgICAgcERhdGEgPSBzLmdldFBvaW50ZXIoKTsKICAgfQpwcml2YXRlOgogICBUKiBwRGF0YTsKfTsKCmNsYXNzIEEge307CmNsYXNzIEIgOiBwdWJsaWMgQSB7fTsKCmludCBtYWluKCkKewogICAgU29tZVRlbXBsYXRlPEI+IGIobmV3IEIoKSk7CiAgICBTb21lVGVtcGxhdGU8QT4gYShiKTsKICAgIHJldHVybiAwOwp9