C++ Classn Overloading

#include <cstdlib>
#include <iostream>

using namespace std;

class Kabisat{
friend ostream& operator<<(ostream&, Kabisat&);
friend istream& operator>>(istream&, Kabisat&);

public:
Kabisat(){};

void proses(){
if(tahun%4==0){
hasil = “Tahun Kabisat”;
}else hasil = “Bukan Tahun Kabisat”;
}

private:
int tahun;
char *hasil;
};

istream& operator>>(istream& in, Kabisat& masukkan){
cout<<“Masukkan Tahun = “;
in >>masukkan.tahun;

return in;
}

ostream& operator<<(ostream& out, Kabisat& keluaran){
cout<<“Tahun “<<keluaran.tahun<<” adalah “<<keluaran.hasil;

return out;
}

int main(int argc, char *argv[])
{
Kabisat tahun;
cin >> tahun;
tahun.proses();
cout<< tahun;
cout<< endl;

system(“PAUSE”);
return 0;
}

Tinggalkan Balasan

Please log in using one of these methods to post your comment:

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