// Default constructor
// Constructor that specifies a unit
Unit(int h, int a, int w, int c, int m, int p, int r, bool l, int x, int y);
// Unit moves across arena, returns whether it's a legal movement. Takes in coordinates as arguments.
bool Move(char board, int x, int y);
//....there's also setter and getter functions, don't need to post everything
int range;//?????? will have to be a set of coordinates
Yeah, I thought the second one would be the right one.
Here's the error:
Unit.cpp: In member function âbool Unit::Move(char*, int, int)â:
Unit.cpp:63:33: error: invalid types âchar[int]â for array subscript
Unit.cpp:66:33: error: invalid types âchar[int]â for array subscript
I actually looked at that exact article before making this topic, but I found it unhelpful because it deals with single-dimensional arrays, and also my array is being passed around three different programs (Unit.h, Unit.cpp, Game.cpp).
I also did what you said...and it still refuses to compile.
When you said call the function the way you called it previously, I presume you meant the way I had it in they very first post?
These are my three lines of interest:
From the Unit.h bool Move(char board, int x, int y);
From the Unit.cpp bool Unit:: Move(char *board, int x, int y)
From the Game.cpp Alexander.Move(board[r][c], 3, 9);
I think it's worth noting that I also did this (and it doesn't work either)
I figured that may be the case, and I had tried it out as well, and it still didn't compile.
This is what I have:
From Unit.h bool Move(char *board, int x, int y);
From Unit.cpp bool Unit:: Move(char *board, int x, int y)
From Game.cpp Alexander.Move(board, 3, 9);
Exactly what you said, right??
I don't get why it won't work... I don't know if this will help, but here's the error:
Game.cpp: In function âint main()â:
Game.cpp:39:28: error: no matching function for call to âUnit::Move(char , int, int)â
Game.cpp:39:28: note: candidate is:
In file included from Game.cpp:12:0:
Unit.h:21:8: note: bool Unit::Move(char**, int, int)
Unit.h:21:8: note: no known conversion for argument 1 from âchar â to âchar**â