overloading

#include <cstdlib>
#include <iostream>

using namespace std;
class contoh{
friend istream&operator>>(istream&,contoh&);
friend ostream&operator<<(ostream&,contoh&);
public:
int proses(){return(a<b?b:a);
}
private:
int a,b;
};

istream&operator>>(istream&in,contoh&masukan){

cout<<”masukan bilangan pertma :”;
in>>masukan.a;
cout<<”masukan bilangan kedua :”;
in>>masukan.b;
}
ostream&operator<<(ostream&out,contoh&keluaran){
out<<”nilai max nya :”<<keluaran.proses();
}

int main(int argc, char *argv[])
{
contoh Contoh;
cin>>Contoh;
cout<<Contoh;
cout<<endl;

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