c++友元函数访问问题
#include<iostream>using namespace std;
class Time
{
friend ostream &operator<<(ostream &output,Time &t);
friend ostream &operator>>(istream &input,Time &t);
private:
int hour;
int minute;
int second;
};
ostream &operator<<(ostream &output,Time &t)
{
output<<t.hour<<"/"<<t.minute<<"/"<<t.second;
return output;
}
ostream &operator>>(istream &input,Time &t)
{
input.ignore();
input>>t.hour;
input.ignore(2);
input>>t.minute;
input.ignore();
input>>t.second;
return input;
}
int main()
{
Time t;
cin>>t;
cout<<t;
}
为什么会是没有访问权限?友元函数是可以访问累的私有成员啊