C++ Benutzen eines std::Vectors

F

Furtano

Gast
Hi,


warum wird mir in Zeile 30 folgender Fehler angezeigt?
Versteh ich nicht :(.

Error 2 error C2440: 'initializing' : cannot convert from 'void' to 'sf::RectangleShape' c:\users\christian\desktop\uni\8_semester\code\sdl1\sdl1\ameise.cpp 31


LG und vielen Dank,
Furtano

PHP:
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>
#include <cstdlib>
#include <iostream>
#include <Windows.h>
#include "Globals.h"
#include "Lanton.h"
using namespace std;

int main (){
	 sf::RenderWindow window(sf::VideoMode(600, 600), "My window");
	 float i = 0;

	 bool timeOver = false;
	 bool  langtonField[SIZE][SIZE];
	 std::vector <sf::RectangleShape> gridhey;
	 int spaceCounter = 0;
	 sf::Clock clock;
		
	 // 1000 Quadrate anlegen
	 int rectangleSize = 600/SIZE;
		for (int y = 0; y < 600; y = y+= rectangleSize){
			for (int x = 0; x < 600; x += rectangleSize){	
					sf::RectangleShape shape(sf::Vector2f(rectangleSize ,rectangleSize));
					shape.setFillColor(sf::Color(255,255,255));
					shape.setPosition((float)x, (float)y);
					shape.setOutlineThickness(1);
					shape.setOutlineColor(sf::Color(0,0,0));
					gridhey.push_back(shape);
					sf::RectangleShape bla = gridhey.pop_back();
			}
				
		}
}
 
Definition von pop_back() ansehen?
Ich glaube nicht, dass du verstanden hast, was die Funktion macht und du verwendest sie einfach falsch.
Was du willst ist das letzte Element erhalten, dazu gibt es die Funktion back().

Gruß
BlackMark
 

Ähnliche Themen

T
  • Gelöst
Antworten
3
Aufrufe
655
F
Antworten
4
Aufrufe
1.383
F
Antworten
5
Aufrufe
1.358
F
F
Antworten
2
Aufrufe
1.689
Zurück
Oben