Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Implement two functions: <code>basic_ostream &amp; operator&lt;&lt; (basic_ostream&amp; ostr, const CookieOrder&amp; co)</code> <code>basic_istream &amp; operator&gt;&gt; (basic_istream&amp; istr, CookieOrder&amp; co)</code></p> <p>the <code>operator&lt;&lt;=</code> function will be called when you use <code>cout &lt;&lt; order &lt;&lt; endl;</code> and the <code>operator&gt;&gt;</code> function will be called when you use the <code>&gt;&gt;</code> (stream extraction) operator. Be very careful how you implement the stream extraction operator.</p> <p>You may want to declare either of these as <code>friend</code> to the <code>CookieOrder</code>, as that will allow the function to access the private parts of the class as if the function is a member of the class.</p> <hr> <p>edit to respond to changes in the question</p> <p>delcare your class as before: </p> <blockquote> <p>class CookieOrder {<br> public:<br> // public methods as before<br> private:<br> // private parts as before<br> };<br> <code>basic_ostream</code> &amp; operator&lt;&lt; (basic_ostream&amp; ostr, const CookieOrder&amp; co);<br> <code>basic_istream</code> &amp; operator>> (basic_istream&amp; istr, CookieOrder&amp; co); </p> </blockquote> <p>Implement the two functions using only the public interface of the CookieOrder class.</p> <p>For example:</p> <blockquote> <p><code>basic_ostream</code> &amp; operator&lt;&lt; (basic_ostream&amp; ostr, const CookieOrder&amp; co)<br> {<br> ostr &lt;&lt; co.get_customerName() &lt;&lt; endl;<br> /* the rest of the output */<br> }</p> </blockquote> <p>These functions <strong>are not</strong> members of the CookieOrder class, they are normal functions with no special access to the CookieOrder class or instanaces of the class.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload