title: Print Operator overload fail?
body: <p>Am practicing C++ basic inheritance concepts, came across the need to print out a custom class object and wrote an overload, followed guide exactly yet still does not register use of the new operator for printing (&lt;&lt;).</p>
  
  <p>Am wondering if typed incorrectly or had some declaration/initiation errors somewhere else?</p>
  
  <blockquote>
    <p>no match for ‘operator&lt;&lt;’ (operand types are
    ‘std::basic_ostream’ and ‘Choco’)  std::cout&lt;&lt; "Choco value: "
    &lt;&lt; child &lt;&lt; endl;</p>
  </blockquote>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  class Sweets {
          public:
                  // pure virtual, child MUST implement or become abstract
                  // Enclosing class becomes automatically abstract - CANNOT instantiate
                  virtual bool eat() = 0;
  };
  
  // public inheritance : public -&gt; public, protected -&gt; protected, private only accessible thru pub/pro members
  class Choco : public Sweets {
          public:
  
                  bool full;
  
                  Choco() {
                          full = false;
                  }
  
                  // Must implement ALL inherited pure virtual
                  bool eat() {
                          full = true;
                  }
  
                  // Overload print operator
                  bool operator&lt;&lt;(const Choco&amp; c) {
                          return this-&gt;full;
                  }
  };
  
  int main() {
  
  // Base class object
  //sweets parent;
  Choco child;
  
  // Base class Ptr
  // Ptr value = address of another variable
  Sweets* ptr; // pointer to sweets
  ptr = &amp;child;
  
  std::cout&lt;&lt; "Sweets* value:  " &lt;&lt; ptr &lt;&lt; endl;
  std::cout&lt;&lt; "Choco address: " &lt;&lt; &amp;child &lt;&lt; endl;
  std::cout&lt;&lt; "Choco value: " &lt;&lt; child &lt;&lt; endl; // Printing causes error!
  }
  </code></pre>