|
I have defined a commodity class:
class CMerchandise
{
public:
CMerchandise ();
CMerchandise (string goodsname, string modnum,\
string goodsnum, int count, double price, string provider, string manname);
~ CMerchandise ();
void SetGoodsName (string goodsname);
void SetModelNum (string modnum);
void SetGoodsNum (string goodsnum);
void SetCount (int count);
void SetPrice (double price);
void SetProfits (double profits);
void SetManName (string manname);
void SetProvider (string provider);
string GetGoodsName () const;
string GetModelNum () const;
string GetGoodsNum () const;
string GetManName () const;
string GetProvider () const;
int GetCount () const;
double GetPrice () const;
double GetProfits () const;
// Overload the "<" operator for easy STL sorting
bool operator <(const CMerchandise&m) const
{
return m_nCount> m.m_nCount; // From largest to smallest according to the number of products
}
Ranch
private:
string m_strGoodsName; // Item name
string m_strModelNum; // Product model
string m_strGoodsNum; // Article number
int m_nCount; // Number of products
double m_dwPrice; // commodity purchase price
double m_dwProfits; // commodity profit ()
string m_strProvider; // Provider
string m_strManName; // Person in charge of goods (purchase or sale)
};
typedef list <CMerchandise> MerchandiseList; // Commodity chain
I use the following statement in another class:
Where m_MerchandiseList is defined like this: MerchandiseList m_MerchandiseList;
.........
MerchandiseList * pMerchandiseList = new MerchandiseList;
for (MerchandiseListIte = m_MerchandiseList.begin ();
MerchandiseListIte! = M_MerchandiseList.end (); MerchandiseListIte ++) <-error !!
{
if ((* MerchandiseListIte) .GetGoodsName () == Merchandise.GetGoodsName ()&&
(* MerchandiseListIte) .GetGoodsNum () == Merchandise.GetGoodsNum ()&&
(* MerchandiseListIte) .GetManName () == Merchandise.GetManName ())
{
pMerchandiseList-> push_back (* MerchandiseListIte);
bFlag = true;
}
}
For statement is an error when compiling! I don't know what the reason, please prawn pointing, urgent! !! !!
error C2679: binary '=': no operator defined which takes a right-hand operand of type 'class std :: list <class CMerchandise, class std :: allocator <class CMerchandise>> :: const_iterator' (or there is no acce |
|