I have a class in which I want to create a bitstring from the boost library as a public member of this class. But I get a lot of different errors which I do not understand and want to solve. The following code does compile without errors. I know that the bits are not random, but that doesn't matter yet.
#include <boost/dynamic_bitset.hpp>
class individual{
public:
individual(uint32_t bitStringLength):
bitStringLength_(bitStringLength){}
void createRandomIndividual(){
boost::dynamic_bitset<> gene_(bitStringLength_);
return;
}
private:
uint32_t bitStringLength_;
};
But now if I change my code into
class individual{
public:
individual(uint32_t bitStringLength):
bitStringLength_(bitStringLength){}
boost::dynamic_bitset<> gene_(bitStringLength_);
private:
uint32_t bitStringLength_;
};
my code won't compile and I get the error:
‘bitStringLength_’ has not been declared boost::dynamic_bitset<> gene_(bitStringLength_);
I do not understand why my code gives me this error. Why can't I generate my bitstring in this way?