Selasa, 17 April 2012

Menentukan bangun persegi dan Persegi Panjang(c++)



#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<<"Masukkan panjang:";
             in>>x.p;
             cout<<"masukkan lebar:";
             in>>x.l;
             return in;
             }
             
   ostream& operator<<(ostream& out , bangun& z){    
      if(z.p==z.l){
               out<<"Bangun persegi";

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

Copyright © YunusBasuki® Design by YunusBasuki

HOME