Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <vector>
- using namespace std;
- class Person {
- public:
- string name;
- int age;
- Person() {}
- Person(string n, int a) {
- name = n;
- age = a;
- }
- };
- class Spisak {
- public:
- vector<Person> hora = { Person("pesho", 15), Person("gosho", 25), Person("reni", 34) };
- vector<string> imena() {
- vector<string> names;
- for (Person p : hora) {
- names.push_back(p.name);
- }
- return names;
- }
- };
- int main() {
- Spisak sp;
- for (string i : sp.imena()) {
- cout << i << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement