#include<bits/stdc++.h>
using namespace std;
class tl{
char ten[ 30 ] ;
char mau[ 30 ] ;
float gia;
public :
tl( ) {
strcpy ( ten," " ) ;
strcpy ( mau," " ) ;
gia= 0 ;
}
tl( const char tensp[ 30 ] ,const char mausac[ 30 ] ,float giatien) {
strcpy ( ten,tensp) ;
strcpy ( mau,mausac) ;
gia= giatien;
}
bool operator* ( tl y) {
return ( gia> 250 && strcmp ( mau,"trang" ) == 0 ) ;
}
friend istream& operator>> ( istream& x,tl& y) ;
friend ostream& operator<< ( ostream& x,tl y) ;
bool operator== ( tl y) ;
} ;
istream& operator>> ( istream& x,tl& y) {
cout << "ten :" ; x>> y.ten ;
cout << "mau sac:" ; x>> y.mau ;
cout << "gia: " ; x>> y.gia ;
return x;
}
ostream& operator<< ( ostream& x,tl y) {
cout << "ten :" << y.ten << endl;
cout << "mau sac:" << y.mau << endl;
cout << "gia: " << y.gia << endl;
return x;
}
bool tl:: operator == ( tl y) {
return ( strcmp ( ten,y.ten ) == 0 && strcmp ( mau,y.mau ) == 0 && gia== y.gia ) ;
}
int main( ) {
tl a( "LG" ,"trang" ,2000 ) ;
tl b;
cout << "thong tin tu lanh a: " << endl;
cout << a<< endl;
cout << "nhap thong tin tu lanh b" << endl;
cin >> b;
ofstream f( "tl.txt" ) ;
if ( a* a) {
cout << "tu lanh a co gia >250 & mau trang!" << endl;
f<< "tu lanh a co gia >250 & mau trang!" << endl;
}
else {
cout << "tu lanh a ko co gia >250 & mau trang!" << endl;
f<< "tu lanh a ko co gia >250 & mau trang!" << endl;
}
if ( b* b) {
cout << "tu lanh b co gia >250 & mau trang!" << endl;
f<< "tu lanh b co gia >250 & mau trang!" << endl;
}
else {
cout << "tu lanh b ko co gia >250 & mau trang!" << endl;
f<< "tu lanh b ko co gia >250 & mau trang!" << endl;
}
if ( a== b) {
cout << "2 tu lanh co thong tin giong nhau!" << endl;
f<< "2 tu lanh co thong tin giong nhau!" << endl;
}
else {
cout << "2 tu lanh ko co thong tin giong nhau!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