I want to use a boost::mutex for the function add of my struct Cell. Here is the definition of my struct in Detector.h
class Detector {
private:
    struct  Cell{
        static boost::mutex mutex_;
        double energy;
        double sqrt_energy;
        int histories;
        inline Cell(): energy(0.f), sqrt_energy(0.f), histories(0.f) {
            boost::mutex mutex_;  //I tried with and without this line
        };  
        inline void add(double new_energy) {
            mutex_.lock();
            energy += new_energy;
            sqrt_energy += new_energy*new_energy;
            ++histories;
            mutex_.unlock();
        };
    };
    typedef std::vector<Cell> CellVector;
    CellVector EnergyPrimary;
}
And I use my function add in Detector.cpp on a vector of Cell.
Dectetor::Detector() : {
  nVoxelX=1024;
  nVoxelY=1024;
  size=nVoxelX*nVoxelY;
  EnergyPrimary=CellVector(size);
}
void Detector::Score(int cellID, double new_energy) {
  EnergyPrimary[cellID].add(new_energy);
}
When I try to compile it I have a undefined reference error for mutex_.lock() and mutex_.unlock(). But why is it working before when I overload the operator += with a similar function (and when I called EnergyPrimary[cellID].energy += new_energy;)?
inline bool operator+= (double new_energy) {
    mutex_.lock();
    energy += new_energy;
    mutex_.unlock();
    return false;
};
 
    