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: 
Unless you copy groups by value all the time and the performance is critical, the second way is probably the best. You will get dynamic size vector, and you don't care about freeing memory (vector is stored by value). Also in second and third variant you don't need to store size because vector already has this data.
Programming with dynamic arrays, preferred options is std::vector (option 2).