看板 C_and_CPP 關於我們 聯絡資訊
如題,請問一下,我在我的書上看到了一個範例 其中的一個部份是這樣的 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
chrisdar:並不是。 一個運算子 各自表述 04/07 11:08
tyc5116:???不懂 04/07 11:11
chrisdar:friend ostream& operator<<(ostream& os, Account& a){} 04/07 11:14
chrisdar:這個才是您說的 拿來cout 的 04/07 11:14
chrisdar:回到程式碼上面 把item放進map並且將數量+1 04/07 11:15
tyc5116:喔...大概知道了,謝謝 04/07 16:25