Question: A C++ newer, please do not de-vote...
-------------------------------------

I have the class Group and Person, Group has many Persons. There are many ways to implement this. The following 3 ways are common.

```
// 1. using dynamic pointer. 
class Group {
    Person *persons;
    int size;
public:
    Group(Person *ps, int sz);
};

// 2. using STL container. 
class Group {
    vector<Person> persons;
    int size;
public:
    Group(vector<Person> ps, int sz);
};

// 3. also STL container, but using pointer. 
class Group {
    vector<Person> *persons;
    int size;
public:
    Group(vector<Person> *ps, int sz);
};

```

I wonder that which one is the best way? is there any difference between the latter two ways?
If using pointer, it's possible to have a memory leak.If using reference, we didn't need to consider leak problem, did it?

Answer: 
Assuming `Group` has ownership of `Person`, and you want to avoid copy of the vector, you may move the resource. 

```
class Group {
    std::vector<Person> persons;
public:
    Group(std::vector<Person>&& ps) : persons(std::move(ps)) {}
};

```

And it may be even cleaner to add directly `Person` from `Group` without exposing internal:

```
class Group {
    std::vector<Person> persons;
public:
#if 1
    // generic method,
    template <typename ... Args>
    Person& AddPerson(Args&&... args) {
         persons.emplace_back(std::forward<Args>(args)...);
         return persons.back();
    }
#else
    // but it would be simpler to just use directly
    // the arguments of Person's constructor
    Person& AddPerson(const std::string& name) {
         persons.emplace_back(name);
         return persons.back();
    }
#endif
};

```
Programming with dynamic arrays, preferred options is std::vector (option 2).