Let's say your Piece class has one public constructor, and four methods to move it (left, right, up, and down). Your header file might look something like this:
// piece.h
public class piece
{
private:
static int MAX_X;
static int MAX_Y;
int xPosition, yPosition;
public:
Piece(void);
void moveLeft(void);
void moveRight(void);
void moveUp(void);
void moveDown(void);
};
Your .cpp file might be like so:
// piece.cpp
#include "piece.h"
int Piece :: MAX_X = 20;
int Piece :: MAX_Y = 20;
Piece :: Piece(void)
{
xPosition = MAX_X / 2;
yPosition = MAX_Y / 2;
// other initialization code
}
void Piece :: moveLeft(void)
{
--xPosition;
if(xPosition < 0)
xPosition = 0;
}
void Piece :: moveRight(void)
{
++xPosition;
if(xPosition > MAX_X)
xPosition = MAX_X;
}
void Piece :: moveUp(void)
{
--yPosition;
if(yPosition < 0)
yPosition = 0;
}
void Piece :: moveDown(void)
{
++yPosition;
if(yPosition < 0)
yPosition = MAX_Y;
}
Basically, declarations go in the header file, and definitions go in the code file. Stuff like macros and inline functions go in the header, but (aside from inline functions) you should have no actual code in there.