Note that there are some explanatory texts on larger screens.

plurals
  1. POC++ OverLoading the << again
    primarykey
    data
    text
    <p>So my code is compiling ok - however it is not doing what i hoped :(. </p> <p>Ill try and explain this as best I can -</p> <p>Below is my code that is writing to a file on disk.</p> <pre><code>void NewSelectionDlg::PrintInfoFile() { **CProductListBox b;** ofstream outdata; outdata.open("test.dat", ios::app); // opens the file &amp; writes if not there. ios:app - appends to file if( !outdata ) { // file couldn't be opened cerr &lt;&lt; "Error: file could not be opened" &lt;&lt; endl; exit(1); } outdata &lt;&lt; m_strCompany &lt;&lt; endl; outdata &lt;&lt; m_strAppState &lt;&lt; endl; outdata &lt;&lt; m_strPurpose &lt;&lt; endl; outdata &lt;&lt; m_strChannel &lt;&lt; endl; outdata &lt;&lt; m_strProductName &lt;&lt; endl; **outdata &lt;&lt; b &lt;&lt; endl;** outdata &lt;&lt; endl; outdata.close(); return; } </code></pre> <p>The key lines im concerned about are in Bold. I want to print out a class CProductListBox. Now as this is not a string, etc I know I have to over-ride the &lt;&lt; in order to be able to do this. So my class for CProductListBox looks like this:</p> <pre><code>class CProductListBox : public CListBox { DECLARE_DYNAMIC(CProductListBox) public: CProductListBox(); virtual ~CProductListBox(); **friend std::ostream&amp; operator&lt;&lt; (std::ostream&amp; o, const CProductListBox&amp; b) { return o; }** </code></pre> <p>I have bolded again what i think is important - It is printing nothing on the output file unfortunately were I was hoping it would print the contenets of what is in b (the CProductList class).</p> <p>Can anyone see something stupid I may be missing - Many Thanks,</p> <p>Colly (Ireland)</p>
    singulars
    1. This table or related slice is empty.
    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. 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