-1

I'm trying to overload the comparision operator.

How can i overload the comparison operator == for this function? c++

template <class elemType>
    void ArrayList<elemType>::RetrieveItem(elemType & item, bool& found) {
        for (int i = 0; i < n_element; i++)
        {
            if (data[i].getName() == item.getName())
            {
                found = true;
                item = data[n_element];
            }
        }
Shubham R
  • 6,554
  • 15
  • 48
  • 106

1 Answers1

-1

from the looks of it, you are comparing 2 strings. overloading comparison operator would go into the class definition for whatever getName() returns

You can see lots of information regarding operator overloading in this post

Community
  • 1
  • 1