Feb 15, 2015 at 7:03pm UTC
I am creating a bitvector project, and I'm having a little trouble creating my constructors in the cpp file. here is the header:
class UIntSet
{
public:
//UIntSet();
UIntSet(unsigned long = 64); // construct a BitVector with specified size
UIntSet(const UIntSet&); // copy constructor
~UIntSet(); // destructor
void Insert(unsigned long n);
void Remove(unsigned long n);
void Clear();
bool Member(unsigned long n) const;
bool Empty() const;
size_t Size() const;
size_t Range() const;
UIntSet& operator = (const UIntSet& s);
UIntSet& operator += (const UIntSet& s);
UIntSet& operator *= (const UIntSet& s);
UIntSet& operator -= (const UIntSet& s);
void Dump(std::ostream& os) const;
// used in development & testing; displays underlying bitvector state
and here is what my constructor and copy constructor look like in my .cpp
{
UIntSet::UIntSet (unsigned long size) //constructor
: bv_(size)
{
}
UIntSet::UIntSet (const UIntSet & s) bv_(64) //Copy constructor
{
if (this != &s)
{
bv_ = s.bv_;
}
}
- I am receiving these errors:
./uintset.cpp:10:40: error: definition of ‘UIntSet::UIntSet(long unsigned int)’ is not in namespace enclosing ‘UIntSet’ [-fpermissive]
./uintset.cpp:15:40: error: expected initializer before ‘bv_’
./uintset.cpp:178:2: error: expected ‘}’ at end of input
make: *** [uintset.o] Error 1
am I missing something in my constructor?