You code fails to compile for reason described by others, that you actually do not dereference a pointer (*table)[0][0], in result expression returns wrong type
A C++ reference is an alias of original object "bound" to it, it's literally not possible to get address or value of reference itself, you would obtain address and value of bound object. In some cases reference doesn't have memory representation at all, on others it's actually an address, but standard doesn't define that.
In case of function's argument passed by reference, the object represented by argument expression is bound to to the name of function's parameter, in your case it's the board, until end of function call. After that, if object was temporary and we could somehow store the reference, reference would be dangling:
void foo (Type& a)
{
static Type& ref = a; // BAD idea. this initialization happens only once
// but on second call `ref` may refer to non-existing instance of Type
}
If you for some odd reason need a container that behaves like reference, there is std::reference_wrapper, but it's a class which rarely used directly, rather it is used when implementing containers.
PS. You have another problem, by default char is treated as a letter by streams. You probably would want to store elements of sudoku as a enum or another integral type , or keep in mind that you have to cast.
PPS. I wouldn't use std::vector<std::vector<T>> type here. I would rather go with OOP style and create class that encapsulates board functions, e.g. (it's a sketch laking of some details, e.g. fault protection)
class Sudoku {
public:
enum Number { none = 0, one = 1, two, three, four, five, six, seven, eight, nine};
Sudoku(int N) : rank(N), data(N*N, Sudoku::none) { }
// add more constructors here if needed?
// would allow to address particular element, e.g. board(i,j)
Number operator() (unsigned col, unsigned row) const
{ return data[row*rank + col]; }
Number& operator() (unsigned col, unsigned row)
{ return data[row*rank + col]; }
unsigned size() const {return rank;}
// more operations, resize, a copy operation on board if required?
private:
unsigned rank; // size of board
std::vector<Number> data; // content of board
};
(*table)[0][0].[0]tells the compiler "tablepoints to an array ofvector<vector<char>>and I want the first one". Think of howint x[10]; int * ptr = x; ptr[4] = 5;works.operator[]is supposed to be applied on thevector, not the pointer tovector.