I am using Visual Studio 2005 and Qt 4.3.1.

When I call my class "colors" like this:

colors col;
int r=col.getRed(3);

the value of r is bad (always 0). ¿¿Someone knows why??


My colors.h

Qt Code:
  1. class colors
  2. {
  3. public:
  4. colors();
  5. ~colors();
  6.  
  7. int getRed(int num);
  8. enum{max_colors=17};
  9.  
  10. private:
  11. struct ColorData
  12. {
  13. int num;
  14. QString name;
  15. int R;
  16. int G;
  17. int B;
  18. }Propiedades[max_colors],*p;
  19. };
To copy to clipboard, switch view to plain text mode 

and my colors.cpp

Qt Code:
  1. #include "colors.h"
  2.  
  3. colors::colors()
  4. {
  5. ColorData Propiedades[max_colors] =
  6. {
  7. { 0, "black", 0, 0, 0},
  8. { 1, "white",255,255,255},
  9. { 2, "darkGray",128,128,128},
  10. { 3, "gray",160,160,164},
  11. ...
  12. };
  13. p=&Propiedades[0];
  14. }
  15.  
  16. int colors::getRed(int num)
  17. {
  18. ColorData *q;
  19. q=p;
  20. for (int i=0;i<=max_colors;i++){
  21. if (num==q->num) return q->R;
  22. q++;
  23. }
  24. return 0;
  25. }
To copy to clipboard, switch view to plain text mode