Advertisement
Cherro

Anka #3

Apr 4th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.16 KB | None | 0 0
  1. // Zad 3.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4.  
  5. #include <iostream>
  6. #include <string>
  7. #include <vector>
  8. using namespace std;
  9.  
  10. class Person {
  11. private:
  12.     string name;
  13.     string surname;
  14.     int age;
  15.     string hair_color;
  16.     string address;
  17. public:
  18.     Person(string name, string surname, int age, string hair_color, string address)
  19.     {
  20.         this->name = name;
  21.         this->surname = surname;
  22.         this->age = age;
  23.         this->hair_color = hair_color;
  24.         this->address = address;
  25.     }
  26.  
  27.     string getName()
  28.     {
  29.         return this->name;
  30.     }
  31.     string getSurname()
  32.     {
  33.         return this->surname;
  34.     }
  35.     int getAge()
  36.     {
  37.         return this->age;
  38.     }
  39.     string getAddress()
  40.     {
  41.         return this->address;
  42.     }
  43.     string getHairColor()
  44.     {
  45.         return this->hair_color;
  46.     }
  47. };
  48.  
  49.  
  50. int main()
  51. {
  52.     vector<Person*> people;
  53.     Person *p1 = new Person("Anna", "Huk", 19, "Blonde", "Akademik");
  54.     Person *p2 = new Person("Dominik", "Kaliszewski", 20, "Black", "Kadlubka");
  55.     people.push_back(p1);
  56.     people.push_back(p2);
  57.     for (int i = 0; i < people.size(); i++)
  58.         cout << people[i]->getName() << " " << people[i]->getSurname() << " " << people[i]->getAge() << endl;
  59.     getchar();
  60.     return 0;
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement