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
- 12 DE OCTUBRE: ACADEMIA SANROQUE ADAPTA SU ACTIVIDAD CON MOTIVO DEL DÍA DE LA FIESTA NACIONAL DE ESPAÑA

- ANÁLISIS DE LOS RESULTADOS DE ESPAÑA EN PISA 2025 (PUBLICADOS EN 2026): PRINCIPALES MOTIVOS DE LA BAJA PUNTUACIÓN – PARTE 3.

- LA IMPORTANCIA DE LAS CERTIFICACIONES OFICIALES DE IDIOMAS DE LAS ESCUELAS OFICIALES DE IDIOMAS PARA EL ALUMNADO DE SECUNDARIA

- CURSO INTENSIVO DE SMR: SISTEMAS MICROINFORMÁTICOS Y REDES

- ANÁLISIS DE LOS RESULTADOS DE ESPAÑA EN PISA 2025 (PUBLICADOS EN 2026): EVOLUCIÓN DURANTE LOS ÚLTIMOS VEINTE AÑOS – PARTE 2.

- CURSOS INTENSIVOS ASIR: ADMINISTRACIÓN DE SISTEMAS INFORMÁTICOS EN RED

- ANÁLISIS DE LOS RESULTADOS DE ESPAÑA EN PISA 2025 (PUBLICADOS EN 2026): UNA REFLEXIÓN SOBRE LAS COMPETENCIAS CLAVE PARA EL SIGLO XXI – PARTE 1.

- CURSOS INTENSIVOS PARA LAS OPOSICIONES AL CUERPO DE INFORMÁTICOS DEL ESTADO Y LAS ADMINISTRACIONES PÚBLICAS.

- CURSOS INTENSIVOS PARA LAS OPOSICIONES A LAS ADMINISTRACIONES PÚBLICAS

- ACADEMIA SANROQUE CUIDA LAS LETRAS Y LAS HUMANIDADES.

- CLASES DE PSICOLOGÍA, PSICOMETRÍA, PSICOBIOLOGÍA Y OTRAS.

- ACADEMIA SANROQUE: LAS CIENCIAS SON UNA ESPECIALIDAD MOTIVANTE E ILUSIONANTE.

Contenido restringido


Comments are closed