为什么出错。。。重载
#include<iostream>using namespace std;
class timec
{public:
int h;
int s;
int m;
void print()
{cout<<"shi"<<h<<endl;
cout<<"min"<<m<<endl;
cout<<"s"<<s<<endl}
timec(int a=0,int b=0,int c=0);
timec (int g)
{int h=g;int s=0;int m=0;}
friend timec &operator+(const timec &c1,const timec &c2);
friend timec &operator-(const timec &c1,const timec &c2);
friend ostream &operator<<(ostream &output,const timec &c3);}
timec::timec
{a=h;
b=s;
c=m;}
timec &operator+(const timec &c1,const timec &c2)
{
a=c1.h+c2.h;
b=c1.m+c2.m;
c=c1.s+c2.s;
return timec(a,b,c);
}
time &operator-(const timec &c1,const timec &c2)
{if(c1.h>c2.h)
{a=c1.h-c2.h;}
else a=c2.h-c1.h;
if(c1.m>c2.m)
b=c1.m-c2.m;
else a=c2.m-c1.m;
if (c1.s>c2.s)
c=c1.s-c2.s;
else a=c2.s-c1.s;
return timec(a,b,c);)
ostream &operator<<(ostream &output,const timec &c3)
{if (c3.s>=60)
{b=b-1;
c=c-60;}
if (c3.m>=60)
{a=a+1;
b=b-60;}
output<<c3.timec(a,b,c)<<" ";
return ourput;}
int main(int argc, char* argv[])
{timec ab(12,36,23),cd(12,35,22);
timec f(0,0,0);
f=ab+cd;
f.print();
return 0;
}