Witam, wiecie co zrobić żeby iterator kontenera, listy konkretnie działał dla listy której składnikami są obiekty klasy Point? Dodam że używam w projekcie sfml stąd metody niezwiązane z pytaniem.
Point.h
#pragma once
#include <SFML/Graphics.hpp>
using namespace sf;
class Point :public sf::Drawable
{
public:
Point(float x, float y);
~Point() = default;
friend class Map;
private:
CircleShape object;
float radius{ 5 };
Color color{ 255, 0, 0 };
void draw(RenderTarget& target, RenderStates state) const override;
};
Point.cpp
#include "stdafx.h"
#include "Point.h"
Point::Point(float x, float y)
{
object.setFillColor(color);
object.setRadius(radius);
object.setOrigin(radius, radius);
object.setPosition(x, y);
}
void Point::draw(RenderTarget & target, RenderStates state) const
{
target.draw(this->object, state);
}
plik.h klasy w której tworzę listę punktów
Map.h
#pragma once
#include <SFML/Graphics.hpp>
#include "Point.h"
#include <list>
using namespace sf;
using namespace std;
class Map :public sf::Drawable
{
public:
Map();
~Map() = default;
friend class Guardian;
private:
const int mapSizeX{ 64 };
const int mapSizeY{ 48 };
const int squerSize{ 12 };
int wallMap[48][64];
list<Point> pointList;
list<Point>::iterator it;
Texture wallTexture, emptyTexture;
void draw(RenderTarget& target, RenderStates state) const override;
void addPoint(float x, float y);
void deletePoint(float x, float y);
};
Fragment Map.cpp (funkcja w której obrazuję problem)
void Map::draw(RenderTarget & target, RenderStates state) const
{
for (it = pointList.begin(); it != pointList.end(); ++it) //rysowanie punktów
{
}
}
żaden operator nie pasuje do tych argumentów. Wiecie jak stworzyć taki operator ("=" i "++") prawidłowo i w którym miejscu. A może to nie o to chodzi? dodam, że jeżeli listę zainicjuję w środku funkcji to wtedy kompilator nie widzi tego problemu ale lista staje się bezużyteczna, poniżej ta sytuacja.
list<Point> pointList;
list<Point>::iterator it;
for (it = pointList.begin(); it != pointList.end(); ++it) //rysowanie punktów
{
}
Dziękuję z góry za pomoc.