I don't know how to initalize a static class member without creating an object of this class. Here is my code:
namespace {
class CPassant : public thread
{
private:
static unsigned LastID;
public:
CPassant (unsigned pDelaiArr = 0, unsigned pDelaiDep = 0)
{
(blabla)
}
static void setLastID (unsigned Valeur)
{
LastID = Valeur;
/* error : undefined reference to `(anonymous
namespace)::CPassant::LastID' */
} // setLastID ()
}; // class CPassant
} // anonym namespace
int main ()
{
CPassant::CPassant ().setLastID(0);
// doesn't work too:
// unsigned CPassant::LastID = 0;
return 0;
}
Thanks
NB: I've already looked at those answers, but none of them worked:
stackoverflow.com/ initialize-a-static-member-an-array-in-c
stackoverflow.com/ how-to-initialize-a-static-member