看板 C_and_CPP 關於我們 聯絡資訊
如何在某一class(Student)中 宣告另外一個class(School)的member function為friend function? 目前如果直接宣告另一個class(School)為friend class是沒有問題的 friend class School; 只要我換成 friend void School::SetNo(Student& one_student, const int& num); 就有錯誤訊息 error C2653: 'School' : is not a class or namespace name 我不懂為什麼宣告friend class時認得School是一個class可是換成School::SetNo卻不行 請問該怎麼改才可以達到只有某一個member function為friend呢? -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 114.43.167.240
LPH66:把 School 的宣告放在 Student 前面? 01/19 22:09
tata111:目前已經把School的宣告放在Student上,所以 01/19 22:16
tata111:friend class School;才編的過 01/19 22:17