Reputation: 377
I have this function:
void SetCode(dynamic_bitset<> * c) {
this->_code = c;
this->_size = c->size();
}
Where it says: this->_code = c
, I want to make a copy of c
and put it in this->_code
.
How can i do this?
Upvotes: 0
Views: 544
Reputation: 2016
Given that this->_code
is the same dynamic_bitset<>
as c
. You can just use the assignment operator (this requires _code
to already be initialized, i.e. new
ed):
*_code = *c;
You should probably remove the pointer from the type of this->_code
and use a reference in the parameter instead:
class A {
public:
void foo (boost::dynamic_bitset<T, U>& c)
{
_code = c;
}
private:
boost::dynamic_bitset<T, U> _code;
};
You didn't supply any of the template parameters for dynamic_bitset
so I just chose two fake ones.
Upvotes: 1