Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- class dynamic{
- public:
- template<class T> void recast(){
- redo<T>(this);
- }
- template<class T>void redo(dynamic* x){
- delete this;
- x = new T;
- }
- virtual void call(void) =0;
- };
- class inherited : public dynamic{
- void call(void){
- std::cout<<"works!"<<std::endl;
- }
- };
- int main(int argc, char* argv[]) {
- dynamic *d = new inherited;
- for(int i =0; i<227000;i++){
- d->recast<inherited>();
- }
- d->call();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement