#include
#include
using namespace std;
class Bilangan{
friend ostream& operator<<(ostream&, const Bilangan&);
friend istream& operator>>(istream&, Bilangan&);
public:
Bilangan(int a0=0,float b0=0.0):a(a0),b(b0){}
void banding_int(const Bilangan&, const Bilangan&);
Bilangan& operator=(const Bilangan&);
Bilangan operator+(const Bilangan&)const;
Bilangan operator-()const;
protected:
int a;
float b;
};
ostream& operator<<(ostream& out, const Bilangan& x)
{
out << "Bagian integer : " <
}
void Bilangan::banding_int(const Bilangan& x, const Bilangan& y )
{
if (x.a>y.b) cout << x.a <<" ::x lebih besar dari " <
Bilangan& Bilangan::operator=(const Bilangan& x)
{
a=x.a;
b=x.b;
return*this;
}
istream& operator>>(istream& in, Bilangan& x)
{
cout<< "\nMasukkan bagian integer :";
in>> x.a;
cout<< "\nMasukkan bagian float :";
in>> x.b;
return in;
}
Bilangan Bilangan::operator+(const Bilangan& x) const
{ Bilangan cc;
cc.a=a+x.a;
cc.b=b+x.b;
return cc;
}
Bilangan Bilangan::operator-() const
{ Bilangan x;
x.a=-a;
x.b=-b;
return x;
}
class Bil_char : public Bilangan {
friend ostream& operator<< (ostream&, const Bil_char&);
public:
Bil_char(int a0=0, int b0=0, char ch='x')
: Bilangan(a0,b0), c(ch) {}
private:
char c;
};
ostream& operator<< (ostream& out, const Bil_char& x)
{
out << "Bagian integer : " <
}
int main(){
Bilangan s, t(-2,3.14),d;
cout << " Nilai awal s\n " << s;
cout << " Nilai awal t dari deklarasi\n "<
cout<<"setelah s di-assign t\n";
cout<<"nilai s\n"< cout << " Masukkan nilai-nilai objek d";
cin>> d ;
cout << " Setelah d + t => \n" <
Bil_char ss;
cout << " Nilai awal ss \n"<< ss;
getch();
}
HASIL :
About Me
Statistik
Live Traffic Feed
Daftar Blog Teman
Link
Blogroll
Didukung
Followers
- Anak Indonesia Harapan Masa Depan (1)
- APBO (1)
- Basis Data (2)
- ERD (1)
- MySQL (1)
- Pendidikan (3)
- Peran Perbankan dan Koperasi dalam mendorong peningkatan kewirausahaan di Indonesia (1)
- PHP (2)
- Programing C++ (8)
- Sewa Ruang Kantor Jakarta Murah (1)
- Sistem Operasi (6)
- Struktur Data (1)
- Web Desain (4)
- Web Dinamis (2)
Langganan:
Postingan (Atom)