overloding balik ukara

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

using namespace std;
class kata{
friend ostream& operator<<(ostream&, kata&);
friend istream& operator>>(istream&, kata&);

public:

char balik_kata();

private:
char Panjang_kata[60];
int A;
int B;

};

istream& operator>>(istream& in,kata& A){

cout<<“BALIK KATA\n”;
cout<<“masukkan kata: “;
in>>A.Panjang_kata;
return in;
}

char kata :: balik_kata(){

cout<<“”<<endl;
A=strlen(Panjang_kata);
cout<<” :”;
for(B=A;B>=0;B–)
{
cout<<Panjang_kata[B];
}
}

ostream& operator<<(ostream& out, kata& A){
out<<“”<<A.balik_kata();
return out;
}

main(){
kata x;
cin>>x;
cout<<x;
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