So I just had a question, In c++11 why do I have to specify the type of a static member to assign to it a value?
Example:
class Player
{
static size_t numOfObj;
public:
Player(){numOfObj++;}
~Player(){numOfObj--;}
}
size_t Player::numOfObj = 0;
In this case why do I have to specify again that numOfObj
is of type size_t
, can't I just do Player::numOfObj = 0;
due to it being already declared?
Thanks in advance.
See Question&Answers more detail:os