#include <iostream>
using namespace std;
class time;
istream & operator >> (istream &in,time &t);
ostream & operator << (ostream &out,time &t);
class time{
public:
int min,sec;
time(){}
time(int m,int s):min(m),sec(s){}
friend ostream & operator << (ostream &out,time &t);
friend istream & operator >> (istream &in,time &t);
};
ostream & operator << (ostream &out,time &t){
out<<t.min<<":"<<t.sec<<endl;
return out;
}
istream & operator >> (istream &in,time &t){
in>>t.min>>":">>t.sec>>endl;
return in;
}
void main(){
time t(10,10),t1(11,11);
cin>>t1;
cout<<t1;
}
错误如下:
error C2679: binary '>>' : no operator defined which takes a right-hand operand of type '' (or there is no acceptable conversion)
Error executing cl.exe.
using namespace std;
class time;
istream & operator >> (istream &in,time &t);
ostream & operator << (ostream &out,time &t);
class time{
public:
int min,sec;
time(){}
time(int m,int s):min(m),sec(s){}
friend ostream & operator << (ostream &out,time &t);
friend istream & operator >> (istream &in,time &t);
};
ostream & operator << (ostream &out,time &t){
out<<t.min<<":"<<t.sec<<endl;
return out;
}
istream & operator >> (istream &in,time &t){
in>>t.min>>":">>t.sec>>endl;
return in;
}
void main(){
time t(10,10),t1(11,11);
cin>>t1;
cout<<t1;
}
错误如下:
error C2679: binary '>>' : no operator defined which takes a right-hand operand of type '' (or there is no acceptable conversion)
Error executing cl.exe.