#include "stdafx.h"
#include <iostream>
#include <functional>
using namespace std;
class Action;
class Drink;
class Eat;
class TestAction;
class Action
{
public:
int operator()(int i)
{
Act(i);
return i;
}
virtual void Act(int i) = 0;
};
class Drink : public Action
{
void Act(int i)
{
cout<<"No. "<<i<<" drink..."<<endl;
}
};
class Eat : public Action
{
void Act(int i)
{
cout<<"No. "<<i<<" eat..."<<endl;
}
};
class TestAction
{
public:
void TestAct(int i, Action& testAct)
{
testAct(i);
}
};
int main(int argc, char* argv[])
{
TestAction doact;
doact.TestAct(0, Drink());
doact.TestAct(1, Drink());
doact.TestAct(2, Drink());
doact.TestAct(0, Eat());
doact.TestAct(1, Eat());
doact.TestAct(2, Eat());
return 0;
}