#109336 - Nil - Fri Nov 17, 2006 11:36 am
Hi,
I am developping a game in C++ for DS and I am stuck with an error when I build my database. I haven't programmed in C++ for several years so I am hoping that I am just making an obvious mistake (well not to me :(). Can you please help me ?
If there is a better path for declaring data in a program (a monster db, or whatever), I will happily take it (and look into source code).
So far what I have done (see source and compile result below):
- declare a class A with the data elements (a pointer to the sprite declaration, its shape and palette Id)
- built an array containing objects of the previous class (A). Ideally I want it to be const (since for that case I will not change its content). I try to declare the variable inside the class B (as private) and then instanciate it in the constructor of class (B)... but I have the same error as what I show below (where the array of A is declare outside of class B).
gfxconstants.h
optionscreen.h
and finally optionscreen.cpp
Output when building:
Can someone help me ?
Thanks in advance,
Nil
Last edited by Nil on Fri Nov 17, 2006 2:42 pm; edited 1 time in total
I am developping a game in C++ for DS and I am stuck with an error when I build my database. I haven't programmed in C++ for several years so I am hoping that I am just making an obvious mistake (well not to me :(). Can you please help me ?
If there is a better path for declaring data in a program (a monster db, or whatever), I will happily take it (and look into source code).
So far what I have done (see source and compile result below):
- declare a class A with the data elements (a pointer to the sprite declaration, its shape and palette Id)
- built an array containing objects of the previous class (A). Ideally I want it to be const (since for that case I will not change its content). I try to declare the variable inside the class B (as private) and then instanciate it in the constructor of class (B)... but I have the same error as what I show below (where the array of A is declare outside of class B).
gfxconstants.h
Code: |
#ifndef _GFXCONSTANTS_H #define _GFXCONSTANTS_H class _gfxfilesDB_{ public: // _gfxfilesDB_(char *pName, unsigned short shape, unsigned short palette) // : name(pName), shape(shape), palette(palette) {} char *name; const unsigned short *sprData; const unsigned short shape; const unsigned short palette; }; #endif //_GFXCONSTANTS_H |
optionscreen.h
Code: |
#ifndef _OPTIONSCREEN_H #define _OPTIONSCREEN_H #include "constants.h" #include "gfxconstants.h" class OptionScreen { public: OptionScreen(); ~OptionScreen(); void Init(); private: }; #endif //_OPTIONSCREEN_H |
and finally optionscreen.cpp
Code: |
#include "optionscreen.h" #include "main.h" #define PANSPRITEPAL 0 const _gfxfilesDB_ gfxGalSize[3]= { {"Small", (unsigned short *)Size_Small_Sprite, OBJ_SIZE_16X32, PANSPRITEPAL}, {"Medium", (unsigned short *)Size_Small_Sprite, OBJ_SIZE_16X32, PANSPRITEPAL}, {"Large", (unsigned short *)Size_Small_Sprite, OBJ_SIZE_16X32, PANSPRITEPAL} }; OptionScreen::OptionScreen() { ... } OptionScreen::~OptionScreen() { ... } void OptionScreen::Init() { ... } |
Output when building:
Code: |
optionscreen.cpp d:/Cpp/Nil/source/optionscreen.cpp:10: error: too many initializers for 'const _gfxfilesDB_' d:/Cpp/Nil/source/optionscreen.cpp:10: error: too many initializers for 'const _gfxfilesDB_' d:/Cpp/Nil/source/optionscreen.cpp:10: error: too many initializers for 'const _gfxfilesDB_' make[1]: *** [optionscreen.o] Error 1 make: *** [build] Error 2 |
Can someone help me ?
Thanks in advance,
Nil
Last edited by Nil on Fri Nov 17, 2006 2:42 pm; edited 1 time in total