Here is Cell.cpp:
#include "Cell.h"
Cell::Cell(int x, int y) {
this->x = x;
this->y = y;
}
Here is my vector declaration:
std::vector<std::vector<Cell>> mazeGrid;
And here is where I try to set the vector at [i][j] to a cell object:
void Grid::generateCells() {
for (int i = 0; i < rows; ++i) {
for (int j = 0; j < cols; ++j) {
Cell temp(i, j);
mazeGrid.at(i).at(j) = temp;
}
}
}
And the generateCells() method gives me this error: Severity Code Description Project File Line Suppression State Error (active) E1776 function "Cell::operator=(const Cell &)" (declared implicitly) cannot be referenced -- it is a deleted function Maze C:\Users\jbcal\source\repos\Maze\Maze\Grid.cpp 18
and
Severity Code Description Project File Line Suppression State Error C2280 'Cell &Cell::operator =(const Cell &)': attempting to reference a deleted function Maze C:\Users\jbcal\source\repos\Maze\Maze\Grid.cpp 18
Does anyone know how to do this correctly?
copy/paste code: Grid.h:
#pragma once
#ifndef GRID_H
#define GRID_H
#include <iostream>
#include <SFML/Graphics.hpp>
#include <vector>
#include "Cell.h"
class Grid {
public:
/*
holds the maze as a vector
*/
std::vector<std::vector<Cell>> mazeGrid;
/*
constructor to make
a maze grid with n rows and cols
*/
Grid(int rows, int cols);
/*
draws all the cells
*/
void Draw(sf::RenderWindow& window);
void generateCells();
private:
int rows;
int cols;
};
#endif
Grid.cpp:
#include "Grid.h"
Grid::Grid(int rows, int cols) {
// rows is always height / 50 (cellHeight)
// cols is always width / 50 (cellWidth)
this->rows = rows;
this->cols = cols;
}
void Grid::Draw(sf::RenderWindow& window) {
}
void Grid::generateCells() {
for (int i = 0; i < rows; ++i) {
for (int j = 0; j < cols; ++j) {
Cell temp(i, j);
mazeGrid.at(i).at(j) = temp;
// why no worky :(
}
}
}
Cell.cpp:
#include "Cell.h"
Cell::Cell(int x, int y) {
this->x = x;
this->y = y;
}
Cell.h:
#pragma once
#ifndef CELL_H
#define CELL_H
#include <SFML/Graphics.hpp>
class Cell {
public:
/*
constructor to make a cell
at row x and column y
*/
Cell(int x, int y);
private:
int x;
int y;
const int cellWidth = 50;
const int cellHeight = 50;
sf::RectangleShape cellRect;
};
#endif