#include <cstdlib>
#include <iostream>
using namespace std;
class BangunDatar {
public:
BangunDatar(){cout<<"class BangunDatar dibangun"<<endl;};
~BangunDatar(){ cout<<"class BangunDatar dibantai"<<endl;};
void input(){
int input;
cout << "Masukkan sisi persegi =";
cin>>input;
s=input;
}
void kotak(){
int luas = s*s;
}
void output(){
cout<<"Luas ="<<luas<<endl;
}
private:
int luas;
int s;
};
int main(int argc, char *argv[])
{
BangunDatar a;
a.input();
a.kotak();
a.output();
system("PAUSE");
system("PAUSE");
return EXIT_SUCCESS;
}
END!!
#include <cstdlib>
#include <iostream>
using namespace std;
class kotak{
public:
kotak(){cout<<"masukkan sisi=";cin>>s;}
double volumekubus(double);
~kotak(){}
private:
double s,hasil;
};
double kotak::volumekubus(double sisi){
sisi=s;
cout<<"volume kubus =";
return(sisi*sisi*sisi);
}
int main(int argc, char *argv[])
{
kotak kotak;
double s;
cout<<kotak.volumekubus(s);
cout<<endl;
system("pause");
return 0;
system("PAUSE");
return EXIT_SUCCESS;
}
#include <cstdlib>
#include <iostream>
using namespace std;
class kotak{
public:
kotak(){cout<<"masukkan sisi=";cin>>s;}
double volumekubus(double);
~kotak(){}
private:
double s,hasil;
};
double kotak::volumekubus(double sisi){
sisi=s;
cout<<"volume kubus =";
return(sisi*sisi*sisi);
}
int main(int argc, char *argv[])
{
kotak kotak;
double s;
cout<<kotak.volumekubus(s);
cout<<endl;
system("pause");
return 0;
system("PAUSE");
return EXIT_SUCCESS;
}
Tidak ada komentar:
Posting Komentar