No matching function call, std::array problem

I'm writing a chess program that i can hopefully later put graphics in with sfml. Right now, i'm stuck because I can't seem to call a simple drawboard function.
Right now i'm not worried about it being weird(setBoard calling drawBoard etc) but just trying to get it compile and print the damned thing.

main.cpp
1
2
3
4
5
6
7
8
9
10
11
12

#include <iostream>

#include "board.h"

int main()
{

	Board * b = new Board();
	b->setBoard();
	
}


board.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#ifndef BOARD_H_
#define BOARD_H_

#include <iostream>
#include <array>



class Board
{
	std::array<std::array<char, 8>, 8> board 
			{{
		        { -2 ,  -3 ,  -4 ,  -5 ,  -6 ,  -4 ,  -3 ,  -2 },
		        { -1 ,  -1 ,  -1 ,  -1 ,  -1 ,  -1 ,  -1 ,  -1 },
		        { 0 ,  0 ,  0 ,  0 ,  0 ,  0 ,  0 ,  0 },
		        { 0 ,  0 ,  0 ,  0 ,  0 ,  0 ,  0 ,  0 },
		        { 0 ,  0 ,  0 ,  0 ,  0 ,  0 ,  0 ,  0 },
		        { 0 ,  0 ,  0 ,  0 ,  0 ,  0 ,  0 ,  0 },
		        { 1 ,  1 ,  1 ,  1 ,  1 ,  1 ,  1 ,  1 },
		        { 2 ,  3 ,  4 ,  5 ,  6 ,  4 ,  3 ,  2 },
		    }};


	public:

		
	    void setBoard();
	    char posQuery(); 
		//void drawBoard(const std::array<std::array<int, 8>, 8> &n); 

	private:

		void drawBoard(const std::array<std::array<int, 8>, 8>& n); 

};


#endif 


board.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <iostream>
#include <array>

#include "board.h"


void Board::drawBoard(const std::array<std::array<int, 8>, 8> &n)
{
    std::cout << "\n" << std::endl;
    for(int i = 0; i < 8; i++)
    {
        for(int j = 0; j< 8; j++)
        {
            std::cout << n[i][j];
        }
        std::cout << std::endl;
    }
}
    
void Board::setBoard()
{
    drawBoard(board);
}



board.cpp: In member function ‘void Board::setBoard()’:
board.cpp:23:20: error: no matching function for call to ‘Board::drawBoard(std::array<std::array<char, 8>, 8>&)’
drawBoard(board);
^

thats the error im getting, and im not sure why. Thank you!
Your std::array is defined with chars
std::array<std::array<char, 8>, 8> board

Your trying to pass in an std::array define with ints
std::array<std::array<int, 8>, 8>

A char might be implicitly convertible to an int, but a wrapper around them is not.
Well, silly me...

Thank you~ and merry christmas :)
Registered users can post here. Sign in or register to post.