title: Overloading an operator C++: error: no viable overloaded '='
body: <p>My goal is to <strong>overload the '+' operator</strong> so that I can combine a Paragraph object and a Story object. This function should <strong>return a new Story object</strong> with the paragraph attached to the beginning. </p>
  
  <pre><code>Story Paragraph::operator+(const Story&amp; story) {
      Paragraph paragraph;
      Story stry;
  
      Paragraph storyPara = story.paragraph;
      Sentence paraSentence = storyPara.sentence;
  
      paragraph.sentence = this-&gt;sentence + paraSentence;
      stry.paragraph = paragraph;
  
      return stry;
  }
  </code></pre>
  
  <p>However, when I run all my code <em>(A Story object should have a paragraph. A Paragraph object should have a sentence. A Sentence object should have a word, etc.)</em>, I get this error:</p>
  
  <p><strong>error: no viable overloaded '='</strong></p>
  
  <p>This occurs when I try to do the following line:</p>
  
  <pre><code>paragraph.sentence = this-&gt;sentence + paraSentence;
  </code></pre>
  
  <p>I'm not quite sure how to add the sentences together to form a paragraph (to ultimately form &amp; return a new Story). Does anyone know how to approach this problem?</p>