#include <cstdlib>
#include <iostream>
using namespace std;
class Hitung {
private:
int a;
int b;
int jumlah;
public:
Hitung (); //constructor
void input();
int sum ();
void output ();
};
Hitung :: Hitung() {
cout<<"\tclass Hitung \n";
}
void Hitung::input(){
cout<<"input nilai a :";
cin>>a;
cout<<"input nilai b :";
cin>>b;
}
int Hitung::sum(){
jumlah =a+b;
return jumlah;
}
void Hitung ::output(){
cout<<"jumlah "<<a<<"+"<<b<<"="<<sum()<<endl;
}
int main(int argc, char *argv[])
{
Hitung a;
a.input();
a.output();
system("PAUSE");
return EXIT_SUCCESS;
}
0 komentar:
Posting Komentar