If I wanted to count how many objects of a class I make, I could write
Code:
// header.hh
class bob
{
public:
bob() ;
private:
static int bobCount_ ;
}
and then a file with the code and initialization
Code:
// code.cc
#include "header.hh"
bob::bobCount_ = 0 ;
bob::bob()
{
bobCount_++ ;
}
So here is the question. Say I want to instead add each object to a stdlib set? Then my header file is
Code:
// header.hh
#include <set>
class bob
{
public:
bob() ;
private:
static std::set<bob*> bobSet ;
}
and then a file with the code and initialization
Code:
// code.cc
#include "header.hh"
bob::bobSet = ????
bob::bob()
{
bobSet.insert( this ) ;
}
So how do I initialize the set container class? The row of question marks doesn't work!
Brian