Laman

Powered By Blogger

Selasa, 25 Desember 2012

inheritance or inheritance

inheritance or inheritance, a class can have kids classes. and properties owned or inherited by the father of her children, which is in the public and protected, private parts can only be used by classes that have it.

class Bil_float : public Bilangan {
friend istream& operator>>(istream&, Bil_float&);
friend ostream& operator<<(ostream&, const Bil_float&);
private :
float a;
public :
Bil_float(float x=0.0) : a(x){}
void banding_float(const Bil_float& y, const Bil_float& z){
if(y.a>z.a) cout<<y.a<<”:: y lebih besar dari “<<z.a<<”::z”;
else cout<<y.a<<”::y lebih kecil dari”<<z.a<<”::z”;
}
};

istream& operator>>(istream& in, Bil_float& masuk){
cout<<”masukan bilangan”; in>>masuk.a;
return in;
}

ostream& operator<<(ostream& out, const Bil_float& keluar){
out<<”tampilkan bilangan”<<keluar.a;
return out;
}



Tidak ada komentar:

Posting Komentar