#include <iostream>
#include <conio.h>
using namespace std;
class bil{
friend ostream& operator<<(ostream&, bil&);
friend istream& operator>>(istream&, bil&);
public:
bil();
private:
int a,b;
};
bil::bil(){
cout<<"----------------------------------------"<<endl;
cout<<"Program Bilangan Rasional "<<endl;
cout<<"-----------------------------------------"<<endl;
}
istream& operator>>(istream& in, bil& mlebu){
cout<<"masukan Bilangan Ke 1 = ";
in>>mlebu.a;
cout<<"masukan Bilangan ke 2 = ";
in>>mlebu.b;
return in;
}
ostream& operator<<(ostream& out, bil& metu){
cout<<"Keluaran = ";
out<<metu.a<<" / "<<metu.b;;
return out;
}
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
main(int argc, char** argv){
bil x;
cin>>x;
cout<<x;
getch();
return 0;
}
Tidak ada komentar:
Posting Komentar