title: Can a user-defined class have custom behavior with std::cout <<?
body: <p>Suppose I have a class <code>Crate</code>, and it has two members, <code>width</code> and <code>height</code>. Now suppose I want the line <code>std::cout &lt;&lt; myCrate &lt;&lt; '\n';</code> to print this:</p>
  
  <pre><code>#---#
  |   |
  |   |
  #---#
  </code></pre>
  
  <p>if <code>myCrate</code> has  <code>width = 5</code> and <code>height = 4</code>. Different <code>width</code>s and <code>height</code>s should result in different crate sizes. Can I define this behavior, e.g. through overloading the <code>&lt;&lt;</code> operator? How would I go about doing this?</p>
  
  <p>Keep in mind that this is a generic example and not specific to the <code>Crate</code> class above.</p>