I'm making a monopoly game, and I have two arrays of Vectors for coordinates for my 2d array of characters. Below is my board.h where the array is kept in the board class
class Board {
...
Vector propList[40];
Vector coordList[40];
...
public:
...
};
I am getting an error running my program in bash when trying to create the executable, displayed below (there are 2 identical errors for each array)
board.cc:15:8: error: constructor for 'Board' must explicitly initialize the member 'propList' which does not have a default constructor
Board::Board() {
^
./board.h:17:12: note: member is declared here
Vector propList[40];
I have all 40 elements initialized in my board constructor as displayed below
propList[0] = Vector(-1, -1);
propList[1] = Vector(73, 51);
...
propList[39] = Vector(81, 46);
coordList[0] = Vector(81, 54);
coordList[1] = Vector(73, 54);
...
I also tried the following
Vector v = (-1, 1);
propList[0] = v;
...
and receive the same error. Does anybody know what is going on and how to fix it?
edit: I forgot to add my vector code. I had to create a constructor since I can't use C++11 initialization on my computer.
vector.cc
#include "vector.h"
Vector::Vector(int x, int y) : x(x), y(y) {}
vector.h
struct Vector {
Vector(int x, int y);
int x;
int y;
};
Vectorclass requires arguments be passed to the consturctor.Vectordoesn't have a default constructor. It ether needs one or you need a different initialization approach.