Created
May 12, 2021 01:02
-
-
Save Lesliecalvillo/421da10f3b3ba781928de15da404faf7 to your computer and use it in GitHub Desktop.
POO Act9bclase operacion herencia suma resta
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
class operacion{ | |
protected: | |
int a,b,r; | |
public: | |
void datoa(){ | |
cout<<"ingrese primer valor= "<<endl; | |
cin>>a; | |
}//fin de dato a | |
void datob(){ | |
cout<<"ingrese segundo valor= "<<endl; | |
cin>>b; | |
}//fin de dato b | |
void resultado(){ | |
cout<<r<<endl; | |
}//fin de resultado | |
};//fin de clase operacion | |
class suma :public operacion{ | |
public: | |
void operar(){ | |
r=a-b; | |
} | |
};//fin de la clase suma herencia operacion | |
class resta :public operacion{ | |
public: | |
void operar(){ | |
r=a+b; | |
} | |
};//fin de la clase resta herencia operacion | |
int main() | |
{ cout<<"****** suma de a + b+ *****"<<endl; | |
suma objtS; | |
objtS.datoa(); | |
objtS.datob(); | |
objtS.operar(); | |
cout<<"la suma de a + b es = "<<endl; | |
objtS.resultado(); | |
cout<<"*****resta de a - b *******"<<endl; | |
resta OBJTr; | |
OBJTr.datoa(); | |
OBJTr.datob(); | |
OBJTr.operar(); | |
cout<<"la resta de a - b es = "<<endl; | |
OBJTr.resultado(); | |
cout<<"Hecho por leslie calvillo 190260012-9"<<endl; | |
return 0; | |
}//fin de main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
link
https://gist.github.com/Lesliecalvillo/421da10f3b3ba781928de15da404faf7