The following is my .h
#ifndef GRID_H_ #define GRID_H_ #include <array> namespace game{ class Grid{ public: static const int dimension = 10; std::array<int, dimension*dimension> grid; Grid(); int get_cell(int x, int y); }; } #endif /* GRID_H_ */ The following is my .cpp
#include "Grid.h" namespace game { Grid::Grid() { // TODO Auto-generated constructor stub } int get_cell(int i, int j){ return (std::get<(i*dimension+j)>grid); } } Compiler says:
error: 'dimension' was not declared in this scope.
I tried to add the scope resolution operator game::, but it didn't work. How can I access this constant from the header file?
Shouldn't it be a global public variable?! And the include should copy and paste the code from the header file. I don;t understand what's wrong. Sorry for the basic question; I'm new to C++/