#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>
{
 bool operator() (const Person * p) 
    { return p->Age() > 12; }
};

main()
{
  Cont c1;

  fillCont(c1,"data.txt");

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


}





