问题是:定义一个操作对象的容器(可能是一个模板)(将命名为Runner)。操作对象(AO)是执行用户提供的功能的对象。这个想法是,一旦一个动作容器加载了AO,就可以要求它运行或执行它们。执行结果将在Results数组中返回。例如:
AO a1(mul, x, x); //if run method is called it returns x*x
AO a2(add, y, 1); //if run method is called it returns y+1
AO a3(print, s); //if run method is called it prints s on cout
Runner<AO> r = {a1,a2,a3};
所以现在在runner类中我应该如何实现一个构造函数来获取常量数组并知道它的大小
template<typename a>
class runner{
a* m;
int size;
public:
runner(const a x[]){
//how to know the size of x[] to initialize m=new a[size] and then fill it with a1,a2,a3 ??
}