#include<bits/stdc++.h>
using namespace std;
class HH{
float d,r,h;
public:
HH(){
d=r=h;
}
HH(float a,float b,float c){
d=a;
r=b;
h=c;
}
float Thetich(){
return d*r*h;
}
friend istream&operator>>(istream &x,HH& y);
friend ostream&operator<<(ostream &x,HH y);
HH operator+(HH y);
};
istream&operator>>(istream &x,HH& y){
cout<<"Chieu dai: "; x>>y.d;
cout<<"Chieu rong: "; x>>y.r;
cout<<"Chieu cao: "; x>>y.h;
// x<<"The tich: "<<y.Thetich()<<endl;
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;
x<<"The tich: "<<y.Thetich()<<endl;
return x;
}
HH HH::operator+(HH y){
HH m;
m.d=d+y.d;
m.r=r+y.r;
m.h=h+y.h;
return m;
}
int main(){
HH h1(2,3,5);
HH h2;
cout<<"Thong tin hh1: "<<endl;
cout<<h1<<endl;
cout<<"Nhap thong tin hh2: "<<endl;
cin>>h2;
ofstream f("hhkthp.txt");
f<<"thong tin hh1: "<<h1<<endl;
f<<"thong tin hh2:"<<h2<<endl;
cout<<"Tong 2 HH la: "<<h1+h2<<endl;
f<<"Tong 2 HH la: "<<h1+h2<<endl;
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKY2xhc3MgSEh7CglmbG9hdCBkLHIsaDsKCXB1YmxpYzoKCQlISCgpewoJCQlkPXI9aDsKCQl9CgkJSEgoZmxvYXQgYSxmbG9hdCBiLGZsb2F0IGMpewoJCQlkPWE7CgkJCXI9YjsKCQkJaD1jOwoJCX0KCQlmbG9hdCBUaGV0aWNoKCl7CgkJCXJldHVybiBkKnIqaDsKCQl9CgkgICAgZnJpZW5kIGlzdHJlYW0mb3BlcmF0b3I+Pihpc3RyZWFtICZ4LEhIJiB5KTsKCQlmcmllbmQgb3N0cmVhbSZvcGVyYXRvcjw8KG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