Contoh Program C++ Operator Overloading:
Nb : Menggunakan Visual Studio 2008
#include "stdafx.h"
#include "iostream"
using namespace std;
class jum
{
public:
int x,y;
jum () {};
jum (int
xx, int yy)
{
x=xx;
y=yy;
}
void
tampil ()
{
cout<<"Input Nilai X =
";cin>>x;
cout<<"Input Nilai Y =
";cin>>y;
}
jum jum::operator
+ (jum ku);
};
jum jum::operator + (jum ku)
{
jum temp;
temp.x = x + ku.x;
temp.y = y + ku.y;
return
(temp);
}
int main()
{
jum a(3,5);
jum b(1,2);
a.tampil ();
b.tampil ();
jum c;
c= a + b;
cout<<endl;
cout<<"Hasil
Penjumlahan 2 Himpunan = "<<c.x<<","<<c.y<<endl;
system ("pause");
return
0;
}
|
Output Program dari Operator Overloading di atas:
|
Contoh
Output Program Overloading
|
Rumit bang............zzzzzzzzzz
ReplyDeleteThe Best Casino Games Near Atlanta, GA 2021 - MapYRO
ReplyDeleteFree Slots and Table Games. 서울특별 출장안마 The best 포천 출장샵 Casino 울산광역 출장샵 in Atlanta is Yuma 영주 출장샵 Casino, 계룡 출장마사지 offering hundreds of slots games from Microgaming and a poker room.