Đoạn code c++ về thời gian này sai ở đâu?

#include<iostream>
using namespace std;
class time{
	int h;
	int m;
	int s;
	public:
		time ( ){
			h=1;
			m=1;
			s=1;
		}
	void nhap();
	void xuat();
	friend time operator+(time a, time b);
	friend time operator-(time a, time b);
};
void time::nhap(){
	do{
		cout<<"nhap HH:MM:SS";
		cin>>h>>m>>s;
	}
	while(0<h||h>23||m>59||m<0||s>59||s<0);
}
void time::xuat(){
	cout<<h<<":"<<m<<":"<<s;
}
time operator+(time a, time b)
{
	time c;
	int n= 3600*a.h+60*a.m+a.s+3600*b.h+60*b.m+b.s;
	c.h=n/3600;
	c.m=(n%3600)/60;
	c.s=(n%3600)%60;
	return c;	
}
main()
{
	time a, b,c;
	a.nhap();
	b.nhap();
	c=a+b;
	c.xuat();
}

em ngồi mò mãi mà k thấy sai ở đâu cả

có báo lỗi j ko bạn?

1 Like

bạn đổi tên class đi là hết lỗi nhé :smile:

2 Likes

ờ đúng oy :slight_smile: tks bác nhé
:smiley:

83% thành viên diễn đàn không hỏi bài tập, còn bạn thì sao?