Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ConsoleApplication4.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #include <vector>
- #include <functional>
- #include <algorithm>
- #include <iostream>
- class Animal
- {
- public:
- Animal();
- ~Animal();
- void live() { age += 5; };
- int getAge(){ return age; };
- int getMaxAge(){ return maxage; };
- bool dead() { return age > maxage; }
- private:
- bool health;
- int age, maxage;
- };
- Animal::Animal()
- {
- age = 0;
- maxage = 3650;
- }
- Animal::~Animal()
- {
- }
- using namespace std;
- int _tmain(int argc, _TCHAR* argv[])
- {
- std::vector<Animal> zoopark(100);
- for (size_t i = 0; i < 100; i++)
- {
- if (i % 2) {
- for (size_t j = 0; j < 3000; j++)
- {
- zoopark[i].live();
- }
- }
- }
- cout << count_if(zoopark.begin(), zoopark.end(),
- mem_fun_ref(&Animal::dead));
- //std::cout << zoopark[1].getAge() << " " << zoopark[1].getMaxAge() << "\n";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement