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
Display All
Display All
If anything in the code isn't understood tell me.
Thanks.
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
- // iVentana.h (iWindow in english ;) )
- #ifndef IVENTANA_H
- #define IVENTANA_H
- #include "Boton.h"
- #include <vector>
- #include <algorithm>
- using namespace std;
- class iVentana
- {
- public:
- iVentana(int nI, int nB);
- ~iVentana();
- void dibujar(SDL_Surface *screen);
- void insertarBoton(Boton *b);
- void insertarFrame(CFrame *f);
- struct DeleteMemObj
- {
- template<typename T>
- void operator()(const T* ptr) const
- {
- delete ptr;
- ptr = NULL;
- }
- };
- protected:
- CSprite *Cimagen;
- vector<Boton*> arrayBoton;
- int activa, nframes;
- };
- #endif
Source Code
- #include "iVentana.h"
- iVentana::iVentana(int nI, int nB):activa(0), nframes(0)
- {
- Cimagen = new CSprite(nI);
- arrayBoton.reserve(nB);
- }
- iVentana::~iVentana()
- {
- Cimagen->finalize();
- for_each(arrayBoton.begin(), arrayBoton.end(), DeleteMemObj());
- }
- void iVentana::insertarFrame(CFrame *f)
- {
- this->Cimagen->addframe(*f);
- }
- void iVentana::insertarBoton(Boton *b)
- {
- this->arrayBoton.push_back(b);
- }
- void dibujar(SDL_Surface *screen)
- {
- for(vector<Boton*>::iterator it = arrayBoton.begin(); it != arrayBoton.end(); it++) //the problem is here
- {
- if((*it) != NULL)
- {
- (*it)->dibujar(screen);
- }
- }
- }
If anything in the code isn't understood tell me.
Thanks.
Be a pointer my friend