fork download
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4. class persona {
  5. private:
  6. string nombre;
  7. int edad;
  8. string hobbie;
  9. public:
  10. persona(string nombre, int edad, string hobbie) {
  11. this->nombre = nombre;
  12. this->edad = edad;
  13. this->hobbie = hobbie;
  14. }
  15. void presentarse() {
  16. cout << "Mi nombre es " << nombre << ", tengo " << edad << "años y me gusta " << hobbie << endl;
  17. }
  18. };
  19. int main() {
  20. persona gabriela("Gabriela", 25, "jugar videojuegos");
  21. gabriela.presentarse();
  22. persona nicole("Nicole", 29, "leer novelas");
  23. nicole.presentarse();
  24. return 0;
  25. }
Success #stdin #stdout 0.01s 5280KB
stdin
Standard input is empty
stdout
Mi nombre es Gabriela, tengo 25años y me gusta jugar videojuegos
Mi nombre es Nicole, tengo 29años y me gusta leer novelas