Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- class I
- {
- public:
- virtual void Release() = 0;
- };
- class A : public I
- {
- public:
- void Release()
- {
- printf("A::Release()\n");
- delete this;
- }
- };
- class Test : public I
- {
- I* i;
- void* p;
- public:
- Test(I* i) : i(i)
- {
- p = *(void**)i;
- }
- void Release()
- {
- printf("Custom release\n");
- *(void**)i = p;
- i->Release();
- delete this;
- }
- };
- template <class T>
- I* Create()
- {
- return new Test(new T);
- }
- int main()
- {
- Create<A>()->Release();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement