#include<bits/stdc++.h>
using namespace std;
class HH{
float d,r,h;
public:
friend istream&operator>>(istream&x,HH&y);
friend ostream&operator<<(ostream&x,HH y);
HH(){
d=h=r=0;
}
HH(float a,float b,float c){
d=a;
r=b;
h=c;
}
bool operator==(HH y);
HH operator+(HH y);
HH operator-(HH y);
};
istream&operator>>(istream&x,HH &y){
cout<<"nhap chieu dai :"; x>>y.d;
cout<<"nhap chieu rong: "; x>>y.r;
cout<<"nhap chieu cao: "; x>>y.h;
return x;
}
ostream&operator<<(ostream&x,HH y){
x<<"Chieu dai: "<<y.d<<endl;
x<<"Chieu rong: "<<y.r<<endl;
x<<"Chieu cao: "<<y.h<<endl;
return x;
}
bool HH::operator==(HH y){
if(y.d==d&&y.r==r)
return true;
else return false;
}
HH HH::operator+(HH y){
HH c;
c.d=d+y.d;
c.r=r+y.r;
c.h=h+y.h;
return c;
}
HH HH::operator-(HH y){
HH c;
c.d=d-y.d;
c.r=r-y.r;
c.h=h-y.h;
return c;
}
int main(){
HH h1(2,3,5);
cout<<"Thong tin hh1: "<<endl;
cout<<h1<<endl;
HH h2;
cout<<"nhap thong tin hh2: "<<endl;
cin>>h2;
HH T=h1+h2;
HH H=h1-h2;
ofstream f("hh.txt");
cout<<"Tong 2 hh : "<<T<<endl;
f<<"Tong 2 hh : "<<T<<endl;
cout<<"Hieu 2 hh:"<<H<<endl;
f<<"Hieu 2 hh:"<<H<<endl;
if(h1==h2==true){
cout<<"2 hh co cung chieu dai va chieu rong!"<<endl;
f<<"2 hh co cung chieu dai va chieu rong!"<<endl;
}
else{
cout<<"2 k cung chieu dai va chieu rong!"<<endl;
f<<"2 k cung chieu dai va chieu rong!"<<endl;
}
f.close();
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKY2xhc3MgSEh7CglmbG9hdCBkLHIsaDsKCXB1YmxpYzoKCQlmcmllbmQgaXN0cmVhbSZvcGVyYXRvcj4+KGlzdHJlYW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