|
我定义了一个商品类:
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;
//重载"<"运算符,便于使用STL排序
bool operator<(const CMerchandise &m) const
{
return m_nCount > m.m_nCount; //按商品数量从大到小排
}
private:
string m_strGoodsName; //货名
string m_strModelNum; //商品型号
string m_strGoodsNum; //货号
int m_nCount; //商品数量
double m_dwPrice; //商品进货价格
double m_dwProfits; //商品利润()
string m_strProvider; //供货商
string m_strManName; //商品负责人(进货或者销售)
};
typedef list<CMerchandise> MerchandiseList; //商品链
我在另一个类中使用下面语句:
其中m_MerchandiseList是这样定义的: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语句就是报错!不知道什么原因,请大虾指点,急!!!
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
|
|