program c++nya
01 | #include <cstdlib> |
02 | #include <iostream> |
03 |
04 | using namespace std; |
05 | class Volume{ |
06 | friend ostream& operator<<(ostream&, Volume&); |
07 | friend istream& operator>>(istream&, Volume&); |
08 | public: |
09 | Volume(); |
10 | void volume_kubus(){ |
11 | volume=s*s*s; |
12 | } |
13 | private: |
14 | int s; |
15 | int volume; |
16 | }; |
17 | Volume::Volume(){ |
18 | cout<< "PROGRAM MENGHITUNG VOLUME KUBUS" <<endl; |
19 | } |
20 | istream& operator>>(istream& in, Volume& masukan){ |
21 | cout<< "Masukkan sisi:" ; |
22 | in>>masukan.s; |
23 | return in; |
24 | } |
25 | ostream& operator<<(ostream& out, Volume& keluaran){ |
26 | out<< "sisi kubus:" <<keluaran.s<<endl; |
27 | out<< "Volume Kubus :" <<keluaran.volume<<endl; |
28 | return out; |
29 | } |
30 | int main(int argc, char *argv[]) |
31 | { |
32 | Volume x; |
33 | cin>>x; |
34 | x.volume_kubus(); |
35 | cout<<x; |
36 | system( "PAUSE" ); |
37 | return EXIT_SUCCESS; |
38 | } |
Tidak ada komentar:
Posting Komentar