[C con Clase] Ayuda con estructuras como miembros de clase

David fire ddfire en gmail.com
Mie Mayo 13 13:57:26 CEST 2009


the falta struct antes de hola en el cpp o poner
typedef struct {
int a;
} Hola;
en el punto h.

El 13 de mayo de 2009 6:57, Victor <teny_84 en hotmail.com> escribió:

> Hola,
> Me gustaria que me echaran una mano con un problema relativo a la inclusion
> de un atributo struct dentro de una clase cpp. La estructura esta definida
> en un archivo .h con el siguiente contenido:
>
> #ifndef TENY_H
> #define TENY_H
>
> struct Hola
> {
>    int a;
> };
>
> #endif
>
> En el archivo de la clase que he definido incluyo el archivo teny.h y
> defino un atributo privado del tipo Hola como sigue:
>
> #ifndef CONSOLE_H
> #define CONSOLE_H
>
> #include <vector>
> #include <string>
> #include <stdio.h>
> #include <string.h>
> #include <memory.h>
> #include <unistd.h>
> #include <sys/socket.h>
> #include <netinet/in.h>
> #include <netdb.h>
> #include <signal.h>
> #include <math.h>
> #include <malloc.h>
> #include <ctype.h>
> #include <fcntl.h>
> #include <stdlib.h>
> #include <sys/time.h>
> #include <sys/stat.h>
> #include <sys/errno.h>
> #include <sys/types.h>
> #include <sys/time.h>
> #include <sys/un.h>
> #include <arpa/inet.h>
> #include <time.h>
>
> #include <ipt/ipt.h>
> #include <ipt/message.h>
> #include <ipt/connection.h>
> #include <gt_simulation.h>
>
> #include <gt_ipt_msg_def.h>
>
> #include <FSA_status.h>
> #include <lineutils.h>
> #include <lmadjust.h>
> #include <pthread.h>
>
> #include "teny.h"
>
> const double COMMUNICATOR_SLEEPTIME_SEC = 0.1;
>
> class Console
> {
>
> private:
>    char hostname[100];
>    char console_ipt_port[100];
>    char ipt_home[512];
>    char *suggested_ipt_home;
>    void *status;
>
>    Hola hol;
>
>    IPCommunicator* communicator;
>    IPConnection*  com_link;
>    //Default birth = false
>    bool birth;
>    pthread_t thread1;
>    int debug;
>    Vector position;
>    float heading;
>    float velX, velY;
>    char * DefaultConsoleName;
>
>
> public:
>
>    Console();
>
>
>
> };
>
> #endif // CONSOLE_H
>
> A la hora de compilar obtengo el siguiente error que no logro corregir:
>
> 'Hola' no nombra a un tipo.
>
> He intentado en vez de poner directametne Hola hol, especificar struct Hola
> hol y el nuevo error que me da es:
>
> console.h:53: error: el campo ‘hol’ tiene tipo de dato incompleto
>
> No entiendo muy bien porque no puedo hacer esta definicion. Agradeceria
> cualquier sugerencia, ayuda de como poder solventarlo.
>
> gracias.
> _______________________________________________
> Lista de correo Cconclase Cconclase en listas.conclase.net
> http://listas.conclase.net/mailman/listinfo/cconclase_listas.conclase.net
> Bajas: http://listas.conclase.net/index.php?gid=2&mnu=FAQ




-- 
(\__/)
(='.'=)This is Bunny. Copy and paste bunny into your
(")_(")signature to help him gain world domination.
------------ próxima parte ------------
Se ha borrado un adjunto en formato HTML...
URL: <http://listas.conclase.net/pipermail/cconclase_listas.conclase.net/attachments/20090513/138288d7/attachment-0001.html>


Más información sobre la lista de distribución Cconclase