Industrial Training

Calculator



# include<iostream.h>
#include<conio.h>
#include<stdlib.h>

 

class calculator{
int argument;
int value;
public:
calculator(){//constructor.
cout<<"Enter the values of 'arg' and 'value'.\n";
cin>>argument>>value;
}

void show(void){//displays the private members.
cout<<"argument="<<argument<<endl;
cout<<"value="<<value<<endl;
cout<<"Press any key to continue...\n";
getch();
}

const int compute(int i);
};

//----------------------------------------------------------------

int const calculator::compute(int i){
if (argument==0)
argument=i;
return value;
}

 

 

void main(){
int x;
calculator c1;
c1.show();
x=c1.compute(0);
cout<<"x="<<x<<endl;
c1.show();
x=c1.compute(60);
cout<<"x="<<x<<endl;
c1.show();
calculator c2;
x=c2.compute(70);
c2.show();

system("type 5calcu.cpp");
return;
}

Hi I am Pluto.