Created
September 21, 2012 15:32
-
-
Save yifu/3762203 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <memory> | |
struct A | |
{ | |
virtual void process(); | |
}; | |
struct B : public A | |
{ | |
virtual void process(); | |
}; | |
void A::process() { std::cout << "A process" << std::endl; } | |
void B::process() { std::cout << "B process" << std::endl; } | |
typedef std::auto_ptr<B> (*func_def)(); | |
std::auto_ptr<B> f() | |
{ | |
return std::auto_ptr<B>(new B); | |
} | |
int main() | |
{ | |
// f(); | |
func_def func = f; | |
std::auto_ptr<A> test((*func)()); | |
test->process(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment