#include <cstdlib>
#include <iostream>
using namespace std;
class persegi{
friend istream& operator>>(istream&, persegi&);
friend ostream& operator<<(ostream&, persegi&);
public:
persegi();
void proses();
private:
int l, p;
string cetak;
};
persegi::persegi(){
cout<<"\t\tmenentukan bangun persegi\t\t"<<endl;
cout<<endl;
}
istream& operator>>(istream& in, persegi& masuk){
cout<<"masukkan lebar : "<<endl;
in>>masuk.l;
cout<<"masukkan panjang : "<<endl;
in>>masuk.p;
return in;
}
void persegi::proses(){
if(p==l) cetak = "persegi";
else cetak = "persegi panjang";
}
ostream& operator<<(ostream& out, persegi& keluar){
out<<keluar.cetak<<endl<<endl;
return out;
}
int main(int argc, char *argv[])
{
system("color c7");
persegi x;
cin>>x;
x.proses();
cout<<x;
system("color c7");
system("PAUSE");
return EXIT_SUCCESS;
}
Jumat, 30 Maret 2012
Langganan:
Posting Komentar (Atom)
0 komentar:
Posting Komentar