I'm at an intermediate level when it comes to programming and I came across something that I have yet to learn about.
This code is for a basic Tetris game and it is from this web page: http://javilop.com/gamedev/tetris-tutorial-in-c-platform-independent-focused-in-game-logic-for-beginners/
This is his header file that defines the class Pieces:
#ifndef _PIECES_
#define _PIECES_
class Pieces
{
public:
int GetBlockType (int pPiece, int pRotation, int pX, int pY);
int GetXInitialPosition (int pPiece, int pRotation);
int GetYInitialPosition (int pPiece, int pRotation);
};
#endif // _PIECES_
Now, in his next header file, for a class called Board, he creates a constructor prototype which takes Pieces *pPieces
as an argument. You can see as follows:
class Board
{
public:
Board (Pieces *pPieces, int pScreenHeight);
int GetXPosInPixels (int pPos);
int GetYPosInPixels (int pPos);
bool IsFreeBlock (int pX, int pY);
bool IsPossibleMovement (int pX, int pY, int pPiece, int pRotation);
void StorePiece (int pX, int pY, int pPiece, int pRotation);
void DeletePossibleLines ();
bool IsGameOver ();
private:
enum { POS_FREE, POS_FILLED };
int mBoard [BOARD_WIDTH][BOARD_HEIGHT]; // Board that contains the pieces
Pieces *mPieces;
int mScreenHeight;
void InitBoard();
void DeleteLine (int pY);
};
#endif // _BOARD_
I have never come across something like this before. My question is what is this declaration of *pPieces
that seemingly uses the class name Pieces
as a data type? Can someone explain to me the reason for it? Or what it achieves? Or what this is called so I can read more about it?