首页 > 试题广场 >

假设有下列程序所示的函数符TooBig: funct

[问答题]
假设有下列程序所示的函数符TooBig:
// functor.cpp -- using a functor
#include <iostream>
#include <list>
#include <iterator>
#include <algorithm>
template<class T>  // functor class defines operator()()
class TooBig
{
private:
   T cutoff;
public:
   TooBig(const T & t) : cutoff(t) {}
   bool operator() (const T & v) { return v > cutoff; }
};
void outint(int n) {std::cout << n << " ";}
int main()
{
    using std::list;
    using std::cout;
    using std::endl;
    TooBig<int> f100(100); // limit = 100
    int vals[10] = (50, 100, 90, 180, 60, 210, 415, 88, 188, 201);
    list<int> yadayada(vals, vals + 10); // range constructor
    list<int> etcetera(vals, vals + 10);
 // C++11 can use the following instead
//  list<int> yadayada = (50, 100, 90, 180, 60, 210, 415, 88, 188, 201);
//  list<int> etcetera (50, 100, 90, 180, 60, 210, 415, 88, 188, 201);
    cout << "Original lists:\n";
    for_each(yadayada.begin(), yadayada.end(), outint);
    cout << endl;
    for_each(etcetera.begin(), etcetera.end(), outint);
    cout << endl;
    yadayada.remove_if(f100);              // use a named function object
    etcetera.remove_if(TooBig<int>[200]);  // construct a function object
    cout <<"Trinmed lists:\n";
    for_each(yadayada.begin(), yadayada.end(), outint);
    cout << endl;
    for_each(etcetera.begin(), etcetera.end(), outint);
    cout << endl;
    return 0;
}
则下面的代码有何功能?赋给bo的是什么值?
bool bo - TooBig<int>(10)(15);

这道题你会答吗?花几分钟告诉大家答案吧!