I need to store a list with chemical elements and its properties. I have programmed a class like this:
Qt Code:
  1. class Elementos
  2. {
  3. public:
  4. Elementos();
  5. ~Elementos();
  6. int getZsymbol(char *Symbol);
  7. .....
  8. private:
  9. enum {MaxElem=118,NameLen=16,NN=-999};
  10. struct ElementData
  11. {
  12. int AtomicNumber;
  13. char Symbol[3+1];
  14. char SpanishName[NameLen+1];
  15. char EnglishName[NameLen+1];
  16. char GermanName[NameLen+1];
  17. .....
  18. }Propiedades[MaxElem],*p;
  19. }
To copy to clipboard, switch view to plain text mode 

And in cpp file:

Qt Code:
  1. #include "elementos.h"
  2.  
  3. Elementos::Elementos()
  4. {
  5. ElementData Propiedades[MaxElem] =
  6. {
  7. { 1, "H" , "Hidrógeno" , "Hydrogen" , "Wasserstoff" },
  8. { 2, "He", "Helio" , "Helium" , "Helium"}
  9. ...
  10. };
  11. p=&Propiedades[0];
  12. }
  13.  
  14. int Elementos::getZsymbol(char *Symbol)
  15. {
  16. ElementData *q;
  17. q=p;
  18. string c = string(Symbol);
  19. for (int i=0;i<MaxElem;i++){
  20. string s = string(q->Symbol);
  21. if (c==s) return q->AtomicNumber;
  22. q++;
  23. }
  24. return 0;
  25. }
To copy to clipboard, switch view to plain text mode 

When i compile and use in debug mode works fine, but in release mode don't work.

I think that p=&Propiedades[0]; point to the first element of the Propiedades, but in getZsymbol function this pointer takes a bad value. Someone knows how can I correct this to work fine (debug and release).

Thanks