#include <iostream.h>
#include <fstream.h>
#include <algorithm>
#include <functional>
#include <vector>
#include "person.h"

typedef vector<Person*> Cont;
typedef Cont::iterator Itor;

template <class T> struct printPtr : public unary_function<T, void>
{
  printPtr(ostream& out) : os(out) {}
  void operator() (T x) { os << *x  << endl; }
  ostream& os;
};

void fillCont(Cont& c, char fname[])
{
  ifstream f;
  Person* p;

  f.open(fname);

  p = new Person;
  f >> *p;

  while(f) {
    c.push_back(p);
    p = new Person;
    f >> *p;
  }
  f.close();
}



struct ageGT : public unary_function<Person*, bool>
{
  ageGT(int a) : amt(a) {}
  bool operator() (const Person * p) 
    { return p->Age() > amt; }
  int amt;
};

main()
{
  Cont c1;

  fillCont(c1,"data.txt");
  int num;

  cout << "Enter cutoff: ";
  cin >> num; 

  cout << count_if(c1.begin(),c1.end(),ageGT(num)) << endl;


}





