The easiest way for a grid with lines on it is to have the lines on the actual image file. Basically if a tile image is 32x32 pixels have a 1 pixel border of that image that is black(or whatever color you want) and when it tiles it will be a grid with lines.
Grid based maps are usually stored in a container class of one sort or another. The most basic would be an array. You can use some math and just use a 1 dimension array or store it in a 2d array so you can access each x and y in a more natural way. such as:
int map[10][10] = {
{ 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, 0, 0, 1, 1, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 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, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
};
Where each int represents a different type of tile, the 4 '1's in the middle are different squares than the '0'. Only do this tho if you have a set size level. If you want dynamic size levels there are better approaches to this.
Here's a small example for 2d arrays of set size:
http://www.cplusplus.com/forum/beginner/42045/