I have overloaded + operator for user-defined StringSet class where it unites two StringSets.
StringSet& StringSet::operator+(StringSet& set2) {
    StringSet* temp = new StringSet;
    for (auto i = 0; i < this->getSize(); i++) {
        temp->addSet(this->data[i]);             
    }
    for (auto j = 0; j < set2.getSize(); j++) {
        temp->addSet(set2.data[j]);              
    }
    return *temp;
}
If I don't allocate temp dynamically am unable to use it as
cout << "union is: " << s1+s2 << endl;    // s1 and s2 are StringSet objs created using constructor
The current code works fine for this but, I wonder if I can do this without alloacating temp dynamically or allocating then deleting it in some way.
 
     
    