class Block
{
Block *on;
char *name;
bool white;
bool clear;
bool onTable;
public:
Block(char *nm);
Block(const Block &ob);
void setName(char *nm);
char *getName() const ;
bool isClear();
void setColor(int colour);
bool isWhite()const;
bool isOnTable();
Block *getOn();
void putOn(Block &block);
void putOnTable();
void takeFromTable();
void makeClear();
void flipColor();
void print();
};
I have class like this. Why the declaration of *on pointer like Block *on? Don't we have to write int, float or something like that first? What is the purpose?
Block *getOn() function out of the class declaration is like this;
Block *Block::getOn()
{
return on;
}
I need to return on pointer in this code. Is there any other way to do that?