Selasa, 10 April 2012

Program Class Menghitung Volume Kubus C++


#include <cstdlib>
#include <iostream>
using namespace std;
class kubus{
friend ostream& operator<<(ostream&, kubus&);
friend istream& operator>>(istream&, kubus&);
private:
double s, l, v;
public:
double luas();
double volume();
};
istream& operator>>(istream& in, kubus& input){
cout<<"masukkan sisi kubus& input: ";
in>>input.s;
return in;
}
double kubus::luas(){
l = 6*s*s;
return l;
}
double kubus::volume(){
v = s*s*s;
return v;
}
int main(int argc, char *argv[])
{
kubus x;
cin>>x;
cout<<endl;
system("PAUSE");
return EXIT_SUCCESS;
}

Tidak ada komentar:

Posting Komentar