these 3 things i've been told to never use, Globals I can kinda understand, but static and friends...? wtf
Name:
Anonymous2010-11-09 23:31
ok, i'll try to make it simple for op
class Dice{
private:
int face;
public:
Dice(){srand(time(0));rolar();};
static int FACES=6;
int obtainFace();
void roll();
};
int Dice:obtainFace(){return face;}
void Dice::roll(){face=rand()%FACES + 1;}
Every time you create a new Dice you create a new int "face", but you don't create a new int FACES, that's because it's static, it belongs to the class and not to the instance.