Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Zad 3.cpp : Defines the entry point for the console application.
- //
- #include <iostream>
- #include <string>
- #include <vector>
- using namespace std;
- class Person {
- private:
- string name;
- string surname;
- int age;
- string hair_color;
- string address;
- public:
- Person(string name, string surname, int age, string hair_color, string address)
- {
- this->name = name;
- this->surname = surname;
- this->age = age;
- this->hair_color = hair_color;
- this->address = address;
- }
- string getName()
- {
- return this->name;
- }
- string getSurname()
- {
- return this->surname;
- }
- int getAge()
- {
- return this->age;
- }
- string getAddress()
- {
- return this->address;
- }
- string getHairColor()
- {
- return this->hair_color;
- }
- };
- int main()
- {
- vector<Person*> people;
- Person *p1 = new Person("Anna", "Huk", 19, "Blonde", "Akademik");
- Person *p2 = new Person("Dominik", "Kaliszewski", 20, "Black", "Kadlubka");
- people.push_back(p1);
- people.push_back(p2);
- for (int i = 0; i < people.size(); i++)
- cout << people[i]->getName() << " " << people[i]->getSurname() << " " << people[i]->getAge() << endl;
- getchar();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement