I would leave line 14 alone and remove line 20, so your constructor is just (picking up Branflake's declaration style correction)
1 2 3 4
template <class T>
Set<T>::Set()
{
}
This will leave the Set constructor to call the vector's default constructor automatically.
You will also have to correct getArray() to
1 2 3 4 5
template <class T>
T* Set<T>::getArray()
{
return &data[0]; // get address of first element
}
If you do decide to use new to create your vector (which is a bit pointless: vector does new itself, internally for you. You usually use vector to avoid the dangers of new/delete!), then all your other methods will have to change a bit, too.
template <class T>
void Set<T>::add(T newItem)
{
data->push_back(newItem); // call via pointer
}
template <class T>
int Set<T>::getSize()
{
return data->size(); // call via pointer
}
template <class T>
T* Set<T>::getArray()
{
return &data->at(0); // etc
// As I mentioned about, this was wrong anyway: you need to get the
// address of the first element. For a normal vector variable, you can
// use &data[0];. But calling operator[] through a pointer uses slightly
// painful syntax: &(*data)[0]; or &data->operator[](0);
}