#include <Core/Core.h> using namespace Upp; class CAppli:Moveable<CAppli> { public: String m_appli; int m_count; CAppli(const String& appli) { m_appli = appli; m_count = 0; } String ToString() { String mycout; mycout << " APPLI : " << m_appli; return mycout; } void update() { m_count++; } }; bool operator== (const CAppli& oAppli, const CAppli& oAppliTest) { Cout() << "\n -> test : " << oAppliTest.m_appli << " =? " << oAppli.m_appli; if( oAppli.m_appli == oAppliTest.m_appli) { Cout() << "\n -> result : " << oAppliTest.m_appli << " is equal to " << oAppli.m_appli; return true; } else { Cout() << "\n -> result : " << oAppliTest.m_appli << " is different of " << oAppli.m_appli; return false; } } class CJSON: public Json { public : Vector<CAppli> vAppli; CJSON operator<< (const CAppli& oAppli) { Cout() << "\nTry to add " << oAppli.m_appli; Vector<CAppli>::Iterator it; it = Find(vAppli.Begin(), vAppli.End(), oAppli); if(it != vAppli.End()) { //CAppli apptmp = *it; //<---- IT'S BUG !!!!!!!! //apptmp.update(); //Cout() << "\n <- Why I fall here even if " << apptmp.m_appli << " is different of " << oAppli.m_appli; Cout() << "\n <- Why I fall here?"; } else { Cout() << " not yet in the vector. "; vAppli.Add(oAppli); Cout() << oAppli.m_appli << " added"; } Cout() << "\n-----------\n\n"; return (*this); } }; CONSOLE_APP_MAIN { CAppli appl1("APP1"), appl2("APP2"), appl3("APP3"); CJSON ojson; ojson << appl1 << appl2 << appl3 << appl2; }
[Updated on: Mon, 12 December 2011 11:20]
Report message to a moderator