Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

在vc6.0裡面要如何重載">>"運算子呢??(新手發問)

0 views
Skip to first unread message

妳的名是我的命!

unread,
Jan 17, 2002, 12:09:14 PM1/17/02
to

friend ostream &operator<<(ostream &stream, product p);
{
cin >> p.name >> p.number;
return stream;
}


friend istream &operator>>(istream &stream, product &p)
{
cout << "Number of " << p.name << ": " << p.number << endl;
return stream;
}

這樣重載運算子有錯嗎??因為我在main裡打cout << product;
的時候都會出現error C2593: 'operator >>' is ambiguous
可是我是直接把課本的範例貼上去,應該是不會錯的才對@@
麻煩大家幫我解惑一下,謝謝
--
* Origin: ★ 交通大學資訊科學系 BBS ★ <bbs.cis.nctu.edu.tw: 140.113.23.3>

0 new messages