Created
May 19, 2021 01:06
-
-
Save Lesliecalvillo/7a53bad82c5ca86ee29d97ef5dbf4ad6 to your computer and use it in GitHub Desktop.
POO Act13 clase estudiante herencia persona
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 persona | |
{ | |
private: | |
int Identidad; | |
public: | |
persona();//constructor | |
void capturarPersona(); | |
void establecerPersona(int); | |
int obtenerIdentidad(); | |
void imprimirPersona(); | |
};//fin de clase persona | |
//funciones de la clase persona | |
persona::persona(){ | |
int p=0; | |
establecerPersona(p); | |
}//fin de persona constructor | |
void persona::capturarPersona(){ | |
int id=0; | |
cout<<"ingrese identidad: "<<endl;cin>>id; | |
establecerPersona(id); | |
}//fin capturar persona | |
void persona::establecerPersona(int p){ | |
Identidad=p; | |
}//fin de establecerPersona | |
int persona::obtenerIdentidad(){ | |
return Identidad; | |
}//fin de obtenerIdentidad | |
void persona::imprimirPersona(){ | |
cout<<"\n Identidad de persona: "<<Identidad; | |
}//fin imprimirPersona | |
class estudiante : public persona | |
{ | |
private: | |
int nroCuenta; | |
public: | |
estudiante();//constructor | |
void capturarEstudiante(); | |
void establecerEstudiante(int); | |
int obtenerNroCuenta(); | |
void imprimirEstudiante(); | |
};//fin de clase estudiante | |
//funciones clase estudiante | |
estudiante::estudiante(){ | |
int cuenta=0; | |
establecerEstudiante(cuenta); | |
}//fin estudiante constructor | |
void estudiante::capturarEstudiante(){ | |
int Nc=0; | |
cout<<"ingrese numero de cuenta: ";cin>>Nc; | |
establecerEstudiante(Nc); | |
}//fin capturarEstudiante | |
void estudiante::establecerEstudiante(int c){ | |
nroCuenta=c; | |
}//fin de establecerEstudiante | |
int estudiante::obtenerNroCuenta(){ | |
return nroCuenta; | |
}//fin obtenerNroCuenta | |
void estudiante::imprimirEstudiante(){ | |
cout<<"\n Numero cuenta estudiante: "<<nroCuenta; | |
}//fin imprimirEstudiante | |
int main() | |
{ | |
estudiante e1; | |
cout << "\nCapturando los datos de un estudiante: " << endl; | |
e1.capturarPersona(); | |
e1.capturarEstudiante(); | |
cout << "\nImprimiendo los datos de un estudiante: " << endl; | |
e1.imprimirPersona(); | |
e1.imprimirEstudiante(); | |
cout << endl; | |
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