Note that there are some explanatory texts on larger screens.

plurals
  1. POerror C2593: 'operator <<' is ambiguous
    primarykey
    data
    text
    <p>i have some problems with template operator&lt;&lt; having a code:</p> <pre><code>class Manager { multiset&lt;Advertising*, CompareAddPtr &gt; AddToSend; LinkedList&lt;Client &gt; ClientList; LinkedList&lt;Client &gt; ActiveClientList; list&lt;string&gt; initList; list&lt;string&gt; commandsList; } </code></pre> <p>in this class i try to use this method:</p> <pre><code>void Manager:: PrintAllClientDetialsTofile() { ofstream myfile; myfile.open ("Result.txt",ios::app); myfile &lt;&lt; ClientList; myfile &lt;&lt; "\n"; myfile.close(); } </code></pre> <p>my &lt;&lt; function in the template class:</p> <pre><code>template &lt;class L&gt; ostream &amp; operator&lt;&lt;(ostream&amp; os,const LinkedList&lt;L&gt;&amp; listToprint) { Link&lt;T&gt; * tmp = listToprint-&gt;pm_head; for(int i=0;i&lt;listToprint.GetNumOfElements();i++) { os&lt;&lt;*(tmp-&gt;m_data); tmp=tmp-&gt;m_next; } return os; } </code></pre> <p>i also have template class </p> <pre><code>template &lt;class T&gt; class Link { private: T* m_data; Link* m_next; Link* m_prev; </code></pre> <p>the client class:</p> <pre><code>#pragma once #ifndef _CLIENT_H_ #define _CLIENT_H_ #include &lt;string&gt; #include &lt;set&gt; #include "Advertising.h" #include "Email.h" #include "FaceBook.h" #include "Msn.h" #include "Sms.h" #include "Bill.h" #include &lt;ostream&gt; #include "LinkedList.h" using namespace std; struct CompareAddPtrClient : public std::binary_function&lt;Advertising*, Advertising*, bool&gt; { bool operator()(Advertising* x, Advertising* y) const { if(x-&gt;GetMadeOrderTime()&lt;y-&gt;GetMadeOrderTime()) return true; else return false; } }; class Client { string m_clientname; string m_companyName; string m_cod;//check if have length of 15 string m_telephone; string m_email; int m_lastOrder; int m_orderUntill; multiset&lt;Advertising*, CompareAddPtrClient &gt; m_clientsAdds; LinkedList&lt;Bill &gt; BillsForClient; public: Client(string clientName,string companyName,string cod,string telephone,string email); Client(string clientName); ~Client(void); //getters LinkedList&lt;Bill &gt;* GetClientsBills(){return &amp;BillsForClient;} const string GetTelephoneNum()const {return m_telephone;} const string GetEmail()const{return m_email;} const int GetClientUntill()const{return m_orderUntill;} const int GetLastOrderTime()const{return m_lastOrder;} //setters void UpdateLastTimeMadeOrder(int theday){m_lastOrder=theday;} void UpdateOrderUntill(int theday){m_orderUntill=theday+7;} //functions friend ostream &amp; operator&lt;&lt;(ostream&amp; os,const Client&amp; print); bool operator==(const Client &amp; other)const; void PrintOrdersForClient()const; void AddAdvertuseForClient(Advertising * add); void LastOrdersByClient(); void PrintClientsBills(); }; #endif </code></pre> <p>when i use this function to print my list i get compile error:</p> <blockquote> <p>error C2593: 'operator &lt;&lt;' is ambiguous</p> </blockquote> <p>i found similar question that was asked <a href="https://stackoverflow.com/questions/3319837/ambiguous-operator">the question</a> but i don't understand how to solve this problem.</p> <p>thank you :)</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.
 

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