Programación General > C/C++

 [SOLUCIONADO] Error en constructor de clase

(1/2) > >>

m0skit0:
Error: 5 cframe.cpp new types may not be defined in a return type
Error: 5 cframe.cpp two or more data types in declaration of `cFrame'
Error: 5 cframe.cpp two or more data types in declaration of `cFrame'
Error: 5 cframe.cpp two or more data types in declaration of `cFrame'
Error: 5 cframe.cpp return type specification for constructor invalid


--- Código: C++ ---//cframe.cpp#include "clases.h" cFrame::cFrame(){    frame = NULL;} 
--- Código: C++ ---//clases.hclass cFrame {    private:        BITMAP *frame;        public:        cFrame();        ~cFrame();        void obtener(BITMAP *ob_frame);             void modificar(BITMAP *mod_frame);}; 
 :wacko:  :wacko:

Eternal Idol:
No esta definido BITMAP:
#include <windows.h>

m0skit0:
Perdona, no he incluído toda la información...

En clases.h está:

--- Código: C ---#include <allegro.h> 
Donde sí está definido BITMAP.

Eternal Idol:
Bueno, no se, pero con hacer esto:
//clases.h
typedef int BITMAP;

Ya me compila en VC++ y g++ ...

m0skit0:
Gracias Eternal Idol, pero me sigue sin funcionar:


--- Código: C++ ---typedef int BITMAP; //////////////////Constructores////////////////cFrame::cFrame(){    frame = NULL;} 4 cframe.cpp two or more data types in declaration of `BITMAP'
4 cframe.cpp extraneous `int' ignored
276 gfx.h 'BITMAP' has a previous declaration as `typedef struct BITMAP BITMAP'

O sea que sí reconoce el tipo declarado en gfx.h BITMAP...  <_<  ¿Pero no reconoce "int"?  :argh:


--- Código: C ---typedef struct BITMAP            /* a bitmap structure */{   int w, h;                     /* width and height in pixels */   int clip;                     /* flag if clipping is turned on */   int cl, cr, ct, cb;           /* clip left, right, top and bottom values */   GFX_VTABLE *vtable;           /* drawing functions */   void *write_bank;             /* C func on some machines, asm on i386 */   void *read_bank;              /* C func on some machines, asm on i386 */   void *dat;                    /* the memory we allocated for the bitmap */   unsigned long id;             /* for identifying sub-bitmaps */   void *extra;                  /* points to a structure with more info */   int x_ofs;                    /* horizontal offset (for sub-bitmaps) */   int y_ofs;                    /* vertical offset (for sub-bitmaps) */   int seg;                      /* bitmap segment */   ZERO_SIZE_ARRAY(unsigned char *, line);} BITMAP; Me explico más en profundidad: en clases.h tengo todas las especificaciones de las clases junto con algunas cabeceras:


--- Código: C ---#include <string>#include <allegro.h>#include "tipos.h"#include "constantes.h" Luego por cada clase un .cpp. Pero da el error comentado en el primer post en el constructor, da igual la clase que sea -aunque no tenga BITMAP como atributo-.

Todo esto usando Dev-C++, con el enlazador configurado con -lalleg. De hecho ejemplos más sencillos sí compilan con la librería, pero con C++ ya no...

¿Es posible que se trate del orden en que g++ intenta compilarlo? Aunque no le veo mucho sentido, porque cada .cpp sólo depende de clases.h, que está incluído...  :brickwall: Adjunto clases.h y cframe.cpp por si acaso...  :mellow:

Navegación

[0] Índice de Mensajes

[#] Página Siguiente

Ir a la versión completa