C
Christian Christmann
Hi,
I'm working on my first STL program. My class BitSet
has three private attributes size, curbit and the STL
bit_vector data which contains some bits.
Here is the code for the constructors:
[snip]
BitSet::BitSet()
:last(-1)
{
std::bit_vector<bool> data (INITSIZE*WORDLEN);
size = INITSIZE;
curbit = 0;
}
BitSet::BitSet(const BitSet &bitset)
:size(bitset.size), curbit(0), last(bitset.last)
{
std::bit_vector<bool> data(size*WORDLEN);
// I try to assing the attribute data of bitset to data
data.assing(bitset.data.begin(), bitset.data.end());
}
[snip]
Compiling the code produces the error message:
bitset.cpp: In copy constructor `BitSet::BitSet(const BitSet&)':
bitset.cpp:82: request for member `begin' in `bitset->BitSet::data', which is
of non-aggregate type `bool*'
bitset.cpp:82: request for member `end' in `bitset->BitSet::data', which is of
non-aggregate type `bool*'
Why can't I access bitset.data.begin() within the constructor?
By the way, is this the correct method to copy the attribute data of
bitset to the new created attribute data?
Thanks
Chris
I'm working on my first STL program. My class BitSet
has three private attributes size, curbit and the STL
bit_vector data which contains some bits.
Here is the code for the constructors:
[snip]
BitSet::BitSet()
:last(-1)
{
std::bit_vector<bool> data (INITSIZE*WORDLEN);
size = INITSIZE;
curbit = 0;
}
BitSet::BitSet(const BitSet &bitset)
:size(bitset.size), curbit(0), last(bitset.last)
{
std::bit_vector<bool> data(size*WORDLEN);
// I try to assing the attribute data of bitset to data
data.assing(bitset.data.begin(), bitset.data.end());
}
[snip]
Compiling the code produces the error message:
bitset.cpp: In copy constructor `BitSet::BitSet(const BitSet&)':
bitset.cpp:82: request for member `begin' in `bitset->BitSet::data', which is
of non-aggregate type `bool*'
bitset.cpp:82: request for member `end' in `bitset->BitSet::data', which is of
non-aggregate type `bool*'
Why can't I access bitset.data.begin() within the constructor?
By the way, is this the correct method to copy the attribute data of
bitset to the new created attribute data?
Thanks
Chris