question

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • Sorry for this question because sure that it is a stupid question.
      I'm using STL in my class, and i have created a vector.
      But when i want to use a iterator, problems appear.
      `arrayBoton' undeclared (first use this function)
      The code is in spanish

      C Source Code

      1. // iVentana.h (iWindow in english ;) )
      2. #ifndef IVENTANA_H
      3. #define IVENTANA_H
      4. #include "Boton.h"
      5. #include <vector>
      6. #include <algorithm>
      7. using namespace std;
      8. class iVentana
      9. {
      10. public:
      11. iVentana(int nI, int nB);
      12. ~iVentana();
      13. void dibujar(SDL_Surface *screen);
      14. void insertarBoton(Boton *b);
      15. void insertarFrame(CFrame *f);
      16. struct DeleteMemObj
      17. {
      18. template<typename T>
      19. void operator()(const T* ptr) const
      20. {
      21. delete ptr;
      22. ptr = NULL;
      23. }
      24. };
      25. protected:
      26. CSprite *Cimagen;
      27. vector<Boton*> arrayBoton;
      28. int activa, nframes;
      29. };
      30. #endif
      Display All


      Source Code

      1. #include "iVentana.h"
      2. iVentana::iVentana(int nI, int nB):activa(0), nframes(0)
      3. {
      4. Cimagen = new CSprite(nI);
      5. arrayBoton.reserve(nB);
      6. }
      7. iVentana::~iVentana()
      8. {
      9. Cimagen->finalize();
      10. for_each(arrayBoton.begin(), arrayBoton.end(), DeleteMemObj());
      11. }
      12. void iVentana::insertarFrame(CFrame *f)
      13. {
      14. this->Cimagen->addframe(*f);
      15. }
      16. void iVentana::insertarBoton(Boton *b)
      17. {
      18. this->arrayBoton.push_back(b);
      19. }
      20. void dibujar(SDL_Surface *screen)
      21. {
      22. for(vector<Boton*>::iterator it = arrayBoton.begin(); it != arrayBoton.end(); it++) //the problem is here
      23. {
      24. if((*it) != NULL)
      25. {
      26. (*it)->dibujar(screen);
      27. }
      28. }
      29. }
      Display All

      If anything in the code isn't understood tell me.
      Thanks.
      Be a pointer my friend
    • Your function dibujar(SDL_Surface *screen) needs to have the prefix iVentana:: on it ie.

      Source Code

      1. void iVentana::dibujar(SDL_Surface *screen)
      2. {
      3. for(vector<Boton*>::iterator it = arrayBoton.begin(); it != arrayBoton.end(); it++) //the problem is here
      4. {
      5. if((*it) != NULL)
      6. {
      7. (*it)->dibujar(screen);
      8. }
      9. }
      10. }


      Otherwise the compiler thinks you are just making a function called 'dibujar' in the global namespace
      PC - Custom Built
      CPU: 3rd Gen. Intel i7 3770 3.4Ghz
      GPU: ATI Radeon HD 7959 3GB
      RAM: 16GB

      Laptop - Alienware M17x
      CPU: 3rd Gen. Intel i7 - Ivy Bridge
      GPU: NVIDIA GeForce GTX 660M - 2GB GDDR5
      RAM: 8GB Dual Channel DDR3 @ 1600mhz
    • No worries, we have all had our days where the simplest mistake gives us a ton of trouble.
      PC - Custom Built
      CPU: 3rd Gen. Intel i7 3770 3.4Ghz
      GPU: ATI Radeon HD 7959 3GB
      RAM: 16GB

      Laptop - Alienware M17x
      CPU: 3rd Gen. Intel i7 - Ivy Bridge
      GPU: NVIDIA GeForce GTX 660M - 2GB GDDR5
      RAM: 8GB Dual Channel DDR3 @ 1600mhz
    • If it makes you feel better, I just spent 30 minutes trying to figure out why I was getting None return back for all content set utility scores. Turns out the bug was in this function:

      Source Code

      1. @classmethod
      2. def _get_subaction_content_set_utility_score(cls, content_score):
      3. """
      4. Return the utility of the content set score.
      5. """
      6. if content_score is None:
      7. return None
      8. cls.SUBACTION_AUTONOMY_CONTENT_SCORE_UTILITY_CURVE.get(content_score)


      No matter how experienced you get, you can still make those little stupid mistakes.

      -Rez
    • What language is that, Python?
      PC - Custom Built
      CPU: 3rd Gen. Intel i7 3770 3.4Ghz
      GPU: ATI Radeon HD 7959 3GB
      RAM: 16GB

      Laptop - Alienware M17x
      CPU: 3rd Gen. Intel i7 - Ivy Bridge
      GPU: NVIDIA GeForce GTX 660M - 2GB GDDR5
      RAM: 8GB Dual Channel DDR3 @ 1600mhz
    • Wow a sneek peak into the Sims 4 code? now we know all the secrets, lol just kidding
      PC - Custom Built
      CPU: 3rd Gen. Intel i7 3770 3.4Ghz
      GPU: ATI Radeon HD 7959 3GB
      RAM: 16GB

      Laptop - Alienware M17x
      CPU: 3rd Gen. Intel i7 - Ivy Bridge
      GPU: NVIDIA GeForce GTX 660M - 2GB GDDR5
      RAM: 8GB Dual Channel DDR3 @ 1600mhz
    • RE: question

      I was also going to post some silly code that drove me nuts for about 4 hours, but then again, I am a newbie so I guess there is no need for that. Lol.

      It does make me feel better knowing that I'm not the only one that this happens to!

      PS. I speak more Spanish than English and I though I would never see code written in Spanish..... nice coding Budark!
      Intel i7 3930k
      8GB Mushkin LP @ 2133 mhz
      GTX 680
      Asus Rampage IV Extreme
      Corsair 650w
    • Originally posted by mholley519
      Wow a sneek peak into the Sims 4 code? now we know all the secrets, lol just kidding

      We haven't announced the game so all I can say is that it's a sims game, which doesn't really help you. The last sims game I worked on was medieval.

      -Rez
    • Our whole half of our first term was about working at a company and non disclosure stuff, so I understand :D.
      PC - Custom Built
      CPU: 3rd Gen. Intel i7 3770 3.4Ghz
      GPU: ATI Radeon HD 7959 3GB
      RAM: 16GB

      Laptop - Alienware M17x
      CPU: 3rd Gen. Intel i7 - Ivy Bridge
      GPU: NVIDIA GeForce GTX 660M - 2GB GDDR5
      RAM: 8GB Dual Channel DDR3 @ 1600mhz
    • Yep, that's par for the course. When we're announced, I'll happily post a link to the announcement and answer whatever questions I'm allowed to about it. :)

      -Rez