Guest User

Untitled

a guest
Apr 14th, 2016
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.71 KB | None | 0 0
  1. //
  2. //  main.cpp
  3. //  Family Tree Creator
  4. //
  5. //
  6.  
  7. #include <iostream>
  8. #include <algorithm>
  9. #include <vector>
  10.  
  11. class Person{
  12.     std::string firstName, lastName;
  13.     int birthDay, birthMonth, birthYear;
  14.     int deathDay, deathMonth, deathYear;
  15.    
  16. public:
  17.    
  18.     //Constructor
  19.     Person(std::string fn = "Empty", std::string ln = "Empty", int bd = 14, int bm = 4, int by = 2016, int dd = 14, int dm = 4, int dy = 2016){
  20.         firstName = fn;
  21.         lastName = ln;
  22.         birthDay = bd;
  23.         birthMonth = bm;
  24.         birthYear = by;
  25.         deathDay = dd;
  26.         deathMonth = dm;
  27.         deathYear = dy;
  28.     }
  29.     //Destructor
  30.     ~Person();
  31.     void enterPerson(){
  32.         std::cout << "Enter first name of person: ";
  33.         std::cin >> firstName;
  34.         std::cout << "Enter last name of person: ";
  35.         std::cin >> lastName;
  36.         std::cout << "Enter day, month and year of birth (separated by a space): ";
  37.         std::cin >> birthDay >> birthMonth >> birthYear;
  38.         std::cout << "Enter day, month and year of death (separated by a space): ";
  39.         std::cin >> deathDay >> deathMonth >> deathYear;
  40.     }
  41.    
  42.     void showPerson(){
  43.         std::cout << "Person first and last name: ";
  44.         std::cout << firstName << " " << lastName << std::endl;
  45.         std::cout << "Birth: " << birthDay << "." << birthMonth << "." << birthYear << std::endl;
  46.         std::cout << "Death: " << deathDay << "." << deathMonth << "." << deathYear << std::endl;
  47.     }
  48. };
  49.  
  50. int main() {
  51.    
  52.     std::cout << "How much persons?: ";
  53.     int howMuch;
  54.     std::cin >> howMuch;
  55.    
  56.     Person *tab = new Person[howMuch];
  57.     tab -> enterPerson();
  58.    
  59.     delete [] tab;
  60.    
  61.     return 0;
  62. }
Add Comment
Please, Sign In to add comment