OVER LOADING

36106yqar2xkebp1.jpg36106yqar2xkebp1.jpg36106yqar2xkebp1.jpg

/*——————————————————*/
/* PROGRAM C++ */
/*——————————————————*/
/* Nama: M. Zakqi Hendra A */
/* Kelas:2A */
/* Tanggal: */

#include<stdio.h>
#include<iostream.h>
#include<conio.h>
#include<string.h>

class opstr
{
private:
char kata[20];
public:

void masukan();
void output();
opstr operator + (opstr A);
opstr operator – (opstr A);
opstr operator !();
};

void opstr::masukan()
{
cout<<“Masukkan kata>> “;gets(kata);
}
void opstr::output()
{
cout<<kata;
}

opstr opstr::operator + (opstr A)
{
opstr tmp;
strcpy(tmp.kata,kata);
strcat(tmp.kata,A.kata);
return (tmp);
}

opstr opstr::operator – (opstr A)
{
opstr tmp;
strcpy(tmp.kata,kata);
strcmp(tmp.kata,A.kata);
return(tmp);
}

opstr opstr::operator ! ()
{
opstr tmp;
strcpy(tmp.kata,kata);
strrev(tmp.kata);
return (tmp);
}

void main()
{
clrscr();
opstr X,Y,Z,A,L;
X.masukan();
Y.masukan();

Z=X+Y;
cout<<“\n\nHasil Penjumlahan =”;
Z.output();

cout<<“\n\nHasil Pengurangan =”;
L=X-Y;
L.output();

cout<<“\n\nHasil Pembalik =”;
A=!Z;
A.output();

getch();
}

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

%d blogger menyukai ini: