我有一個名爲'order'的類,另一個名爲'orderbook'。C++,有對象列表的對象:不匹配'operator =='
訂單包含訂單列表。我想要做的是查找訂單中是否存在訂單的某個值(order.security)。
爲此,我創建了一個迭代器,它應該遍歷整個列表以查找該值是否存在。然而,我一定在某處做錯了什麼,因爲我得到以下g ++錯誤:
錯誤:'__first.std :: _ List_iterator < _Tp> :: operator *()=='中的'operator =='不匹配__val「|
注:該功能的arent還沒有全部完成
void matchOrder(order &orderEntry, orderbook &genericBook);
void fillBook(order &orderEntry, orderbook &bookBUY, orderbook &bookSELL)
{
if (orderEntry.side == "S")
{
//Check if any buy can be fulfilled
matchOrder(orderEntry, bookSELL);
}
}
void matchOrder(order &orderEntry, orderbook &genericBook)
{
//scan book, if find a matching SECURITY, check order type and quantity (and price)
list<order>::iterator pos;
pos = find (genericBook.myList.begin(), genericBook.myList.end(), orderEntry);
if (pos != genericBook.myList.end())
cout << "\n\n FOUND ONE!!!!!";
}
參考,以下是我的訂單類:
class order{
public:
void getOrderData(int j, DATA fullData);
string security;
string type;
int quantity;
double price;
string name;
string side;
};
和我的手持訂單類:
class orderbook
{
public:
list<order> myList;
list<order>::iterator it;
void printItOut();
};
'order'overload'operator =='? – chris 2013-04-04 21:03:52
不,「訂單簿」也沒有。我會在頂部添加我的「訂單」類 – msmf14 2013-04-04 21:06:03