Persegi atau persegi panjang

#include <cstdlib>
#include <iostream>
using namespace std;
 class bangun{
 friend ostream& operator<<(ostream&, bangun&);
 friend istream& operator>>(istream&, bangun&);

 public:
 bangun(){};
 void proses(){}

 private:
 int p;
 int l;
 };

istream& operator>>(istream& in, bangun& x){
 cout<<">>>>>>> WELCOME <<<<<<<"<<endl;
 cout<<"Masukkan Panjang: ";
 in>>x.p;
 cout<<endl;
 cout<<"Masukkan Lebar: ";
 in>>x.l;
 return in;
 }

 ostream& operator<<(ostream& out , bangun& z){
 if(z.p==z.l){

 out<<"MERUPAKAN BANGUN PERSEGI"<<endl;

}
 else
 out<<"MERUPAKAN BANGUN PERSEGI PANJANG"<<endl;

 }
 int main(int argc, char *argv[]){
 bangun a;
 cin>>a;
 cout<<a ;
 system("PAUSE");
 return EXIT_SUCCESS;
}

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s