title: How to have a function have different return type? C++
body: <p>I am doing an assignment and my prof gave us this task as part of the assignment. I am still relatively new to C++ so any help. I created the function however I don't understand how he wants to return a blank string if nothing is found but return an integer if it is found. Is that possible somehow without overloading functions? Right now I just have the function set to an integer type and instead of returning a blank string it returns 0 instead. </p>
  
  <p>Here is the task that is part of the assignment. If you could explain your solution so that a dumb person like me can understand it that would be much appreciated.</p>
  
  <p><strong>FindWord</strong> – this member function will take a string as a parameter and search for it within the
  list. If the list is empty or it cannot be found, it returns a blank string value (“”). Otherwise, it
  returns the int value of the index (e.g. the array element number, such as 0, 1, 2, etc.).
  Remember that the == equality comparison operator works on strings that are handled as string
  objects (rather than char data elements) and that you do not need to be case sensitive.</p>
  
  <p>EDIT: Here is my code I have so far</p>
  
  <pre><code>int WordList::FindWord(string word){
  
  if ((listSize = 0)){ // return -1 if no list exists;
      return -1;
  }
  else {
      for (int i =0;i&lt;listSize;i++){ // run loop to check for word/        
          if (word == list[i]) // if word is found then return index
              return i;
       }        
          return -1; // return -1 if word is not found
     }
  }
  </code></pre>