#include <iostream>
using namespace std;
class perkalian {
friend ostream& operator<<(ostream&, const perkalian&);
friend istream& operator>>(istream&, perkalian&);
public:
perkalian();
void hitung_perkaliannya(){hasil = (a*b);}
private:
int a,b;
int hasil;
};
perkalian::perkalian(){
cout << " program mengalikan 2 interger \n";
cout << " selamat berkarya \n";
}
istream& operator >> (istream& in, perkalian& masukkan){
cout << " masukkan nilai a :";
in >> masukkan.a;
cout << " masukkan nilai b :";
in >> masukkan.b;
return in;
}
ostream& operator << (ostream& out, const perkalian& keluaran){
out << " nilai a : " << keluaran.a << endl;
out << " nilai b : " << keluaran.b << endl;
out << " hasil kali interger di atas :" << keluaran.hasil << endl;
return out;
}
int main(int argc, char *argv[])
{
perkalian x;
cin >> x;
x.hitung_perkaliannya();
cout<< x;
system("PAUSE");
return EXIT_SUCCESS;
}
0 comments:
Posting Komentar