#include #include using namespace std; template struct Command { virtual T Execute() = 0; }; struct GetNamesCommand : public Command > { list Execute() { list a; a.push_back( "one" ); a.push_back( "two" ); a.push_back( "three" ); return a; } }; template T ExecuteCommand( Command& command ) { return command.Execute(); } int main( void ) { GetNamesCommand gnc; list names = ExecuteCommand( gnc ); for( list::iterator i = names.begin(); i != names.end(); ++i ) { cout << i->c_str() << endl; } }