Foro de elhacker.net

Programación => Programación C/C++ => Mensaje iniciado por: aryel_1203 en 12 Diciembre 2016, 05:22 am



Título: Ayuda con String en C++
Publicado por: aryel_1203 en 12 Diciembre 2016, 05:22 am
Buenas noches estoy aprendiendo a programar en C++ y hoy intentando con la libreria string me surgieron los siguientes errores en el compilador:

POdrian ayudarme porque salen esos errores porfis

Citar
In file included from main.cpp:3:0:
./Perro.h:13:2: error: stray ‘\303’ in program
  string nombre_dueño;
  ^
./Perro.h:13:2: error: stray ‘\261’ in program
./Perro.h:23:3: error: stray ‘\303’ in program
   void setNombre_Dueño ();
   ^
./Perro.h:23:3: error: stray ‘\261’ in program
./Perro.h:26:3: error: stray ‘\303’ in program
   string getNombre_Dueño(string);
   ^
./Perro.h:26:3: error: stray ‘\261’ in program
./Perro.h:13:9: error: expected ‘;’ at end of member declaration
  string nombre_dueño;
         ^
./Perro.h:13:21: error: ‘o’ does not name a type
  string nombre_dueño;
                     ^
./Perro.h:23:8: error: variable or field ‘setNombre_Due’ declared void
   void setNombre_Dueño ();
        ^
./Perro.h:23:8: error: expected ‘;’ at end of member declaration
./Perro.h:23:26: error: ISO C++ forbids declaration of ‘o’ with no type [-fpermissive]
   void setNombre_Dueño ();
                          ^
./Perro.h:26:10: error: expected ‘;’ at end of member declaration
   string getNombre_Dueño(string);
          ^
./Perro.h:26:33: error: ISO C++ forbids declaration of ‘o’ with no type [-fpermissive]
   string getNombre_Dueño(string);
el .h es este:

Código
  1. #ifndef PERRO_H
  2. #define PERRO_H
  3.  
  4. #include <iostream>
  5. #include <string>
  6.  
  7. using namespace std;
  8.  
  9. class Perro{
  10.  
  11. private:
  12. string nombre_perro;
  13. string nombre_dueño;
  14. string tipo_raza;
  15.  
  16.  
  17. public:
  18.  Perro(){};
  19.  ~Perro(){};
  20.  
  21.  
  22.  void setNombre_Perro ();
  23.  void setNombre_Dueño ();
  24.  void SetRaza ();
  25.  string getNombre_Perro(string);
  26.  string getNombre_Dueño(string);
  27.  string getRaza(string);
  28.  
  29.  
  30. };
  31.  
  32.  


Mod: Los códigos deben ir en etiquetas GeSHi


Título: Re: Ayuda con String en C++
Publicado por: engel lex en 12 Diciembre 2016, 05:29 am
solo se pueden usar para funciones y variables caracteres ascii + reglas de nomenclatura... básicamente nada que se salga de esta tabla... todos tus errores se deben a las "ñ"



(http://www.asciitable.com/index/asciifull.gif)


Título: Re: Ayuda con String en C++
Publicado por: aryel_1203 en 12 Diciembre 2016, 11:35 am
mil gracias! que error tan tonto xd olvide que estaba escribiendo dueño.


Título: Re: Ayuda con String en C++
Publicado por: MCKSys Argentina en 12 Diciembre 2016, 12:40 pm
Yo que tú, le hecharía la culpa al maldito teclado en espaÑol...

Si vas a programar, usa teclado con distribución yanqui (osea, de USA). Tu vida será más sencilla...  :xD

Saludos!