Program Sederhana Menghitung Balok Menggunakan C++

#include <iostream>

using namespace std;

class Balok{
friend ostream& operator<<(ostream&, Balok&);
friend istream& operator>>(istream&, Balok&);
private:
int sisi;
int lp;
int volume;
public:
Balok(){
sisi = 0;
lp = 0;
volume = 0;
}
};

ostream& operator<<(ostream& output, Balok& su){
output<<"sisi Balok = "<<su.sisi<<endl;
output<<"Luas Permukaan = "<<su.lp<<endl;
output<<"Volume = "<<su.volume<<endl;
return output;
}
int main(){
Balok x;
cout<<x;
return 0;
}

Posting Komentar

Lebih baru Lebih lama