Advertisement
Guest User

Untitled

a guest
May 26th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. #include "Slav.h"
  2. #include <fstream>
  3.  
  4. using namespace std;
  5.  
  6. vector <string> Slav::names;
  7. int Slav::_counter = 0;
  8.  
  9. void Slav::init()
  10. {
  11. srand(time(NULL));
  12. ifstream file("names.dat");
  13. copy(istream_iterator<string>(file),
  14. istream_iterator<string>(),
  15. back_inserter(names));
  16. file.close();
  17. }
  18.  
  19. Slav::Slav()
  20. {
  21. static int amountOfNames = (init(), names.size());
  22. _name = names[rand() % amountOfNames];
  23. _id = _counter++;
  24. }
  25.  
  26. string Slav::description()
  27. {
  28. return string(" ") + _name + " [" + to_string(_id) + "]";
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement