Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <conio.h>
- //strcpy()...
- using namespace std;
- class calculadora{
- private:
- float x;
- float y;
- public:
- calculadora (float, float);
- float suma();
- float resta();
- float multiplicar();
- float dividir();
- void datos();
- };
- calculadora::calculadora(float _x, float _y){
- x= _x;
- y= _y;
- }
- void calculadora::datos(){
- cout<<"Valor x : ";
- cin>>x;
- cout<<"Valor y : ";
- cin>>y;
- }
- float calculadora::suma(){
- return x+y;
- }
- float calculadora::resta(){
- return x-y;
- }
- float calculadora::multiplicar(){
- return x*y;
- }
- float calculadora::dividir(){
- return x/y;
- }
- int main(){
- int A,B;
- calculadora a(A,B);
- a.datos();
- cout<<" Suma : ";
- cout<<a.suma()<<endl;
- cout<<" Resta : ";
- cout<<a.resta()<<endl;
- cout<<" Producto : ";
- cout<<a.multiplicar()<<endl;
- cout<<" Dividir : ";
- cout<<a.dividir()<<endl;
- getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement