program :
#include <cstdlib>
#include <iostream>
using namespace std;
class contoh{
public :
contoh(){};
~contoh(){};
void jumlah(){
cout<<"masukkan a :";
cin>>a;
cout<<"masukkan b :";
cin>>b;
cout<<"jumlah a+b ="<<a+b<<endl;
};
int kali(int,int);
private :
int a,b;
};
int contoh::kali(int x, int y){
x=a;
y=b;
return a*b;
};
int main(int argc, char *argv[])
{
contoh obj;
int a,b;
obj.jumlah();
cout<<obj.kali(a,b)<<endl;
system("PAUSE");
return 0;
}
Output :
#include <cstdlib>
#include <iostream>
using namespace std;
class contoh{
public :
contoh(){};
~contoh(){};
void jumlah(){
cout<<"masukkan a :";
cin>>a;
cout<<"masukkan b :";
cin>>b;
cout<<"jumlah a+b ="<<a+b<<endl;
};
int kali(int,int);
private :
int a,b;
};
int contoh::kali(int x, int y){
x=a;
y=b;
return a*b;
};
int main(int argc, char *argv[])
{
contoh obj;
int a,b;
obj.jumlah();
cout<<obj.kali(a,b)<<endl;
system("PAUSE");
return 0;
}
Output :