作者tyc5116 (累人啊....)
看板C_and_CPP
标题[语法] 关於<<运算子
时间Tue Apr 7 11:07:37 2009
如题,请问一下,我在我的书上看到了一个范例
其中的一个部份是这样的
class Account{
typedef map<string,int> Ledger;
Account& operator<<(const string& item){
L[item]++;
return *this;
}
Ledger L;
{
功能就类似cout<<使用的<<运算子的功能
但标示的部份我不懂这样写的意思,有大大可以解释一下吗,谢谢
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 163.18.48.28
1F:推 chrisdar:并不是。 一个运算子 各自表述 04/07 11:08
2F:→ tyc5116:???不懂 04/07 11:11
3F:推 chrisdar:friend ostream& operator<<(ostream& os, Account& a){} 04/07 11:14
4F:→ chrisdar:这个才是您说的 拿来cout 的 04/07 11:14
5F:→ chrisdar:回到程式码上面 把item放进map并且将数量+1 04/07 11:15
6F:→ tyc5116:喔...大概知道了,谢谢 04/07 16:25