Por aquí dejo el código de cómo hacer clases y la herencia en C++:
#include <iostream>
using namespace std;
class Mamifero{
public:
bool sangreCaliente=true;
bool restiraPulmones=true;
string nombre;
void andar(){
cout<<" andar "<<endl;
}
protected:
void ando(){
cout<<" H9 "<<endl;
}
};
class Humano: public Mamifero{
public:
Mamifero desciende;
bool lenguaje=true;
string nombre;
string apellido;
string dni;
protected:
void hablar(){
andar();
ando();
}
};
struct ordenador{
string grafica;
string cpu;
string placa;
string ram;
string caja;
}ordenador;
struct cuarto{
struct ordenador pc;
string mesa;
string silla;
}cuarto;
int main(){
struct ordenador pc1;
struct cuarto cr;
cr.pc=pc1;
Humano jose;
//jose.ando();
jose.desciende.nombre="Mono";
jose.andar();
cout<<"hola"<<endl;
}

NUESTRAS ÚLTIMAS PUBLICACIONES
- LA GUERRA DE LAS MATEMÁTICAS: LA RAÍZ DE LO IMPOSIBLE

- EFECTO DUNNING-KRUGER & SCHOPENHAUER: LA TIRANÍA DE LA IGNORANCIA O LA BANALIDAD DEL INTELECTO.

- EL MÉTODO D’HONDT Y LA REPRESENTACIÓN DEMOCRÁTICA EN ESPAÑA

- ¿ES MÁS INTELIGENTE LA MASA SOCIAL O EL INDIVIDUO? CÓMO ACEPTAMOS DOGMAS SOCIALES AUNQUE SABEMOS QUE SON FALSOS O EQUIVOCADOS.

- 25 DE NOVIEMBRE: DÍA INTERNACIONAL CONTRA LA VIOLENCIA DE GÉNERO

- MÁS DE 50 LISTENING NUEVOS PARA B2. MÁS MATERIAL, MÁS PRÁCTICA, MEJORES RESULTADOS.

- ¡EL GRAN DEBATE!

- 49 AÑOS CAMBIANDO NUESTRA VISIÓN DEL UNIVERSO. LA VOYAYER A UN DÍA LUZ.

- NEWTON VS EINSTEIN: UNA PELEA DE GRAVEDAD

- EL INFORME QUE NO QUIERES QUE LEAN TUS PADRES: EL IMPACTO DEL MAL USO DE LA INTELIGENCIA ARTIFICIAL Y LAS REDES SOCIALES EN EL APRENDIZAJE Y EL RENDIMIENTO ACADÉMICO.

- AVISO: 11 DE NOVIEMBRE – SUSPENSIÓN DE CLASES EN CANARIAS. – NUESTRAS CLASES SERÁN SOLO TELEMÁTICAS.

- 11 DE NOVIEMBRE – ACADEMIA SANROQUE MANTENDRÁ LA ATENCIÓN EN SERVICIOS MÍNIMOS DURANTE LA HUELGA GENERAL.

Contenido restringido


Comments are closed