Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

Using a base class called Collection, I need to implement my derived class, VariableArray. However, I keep getting the error message

undefined reference to `Collection::Collection()'

I am not certain what I need to do here. I have a constructor defined(none virtual in my base class), along with a copy constructor, and a virtual destructor. In the derived class definition file, I included the code below, but I still get the error message.

VariableArray::VariableArray():Collection()
  {         }

Please any help will be appreciated.

BASE CLASS

#include <iostream>
using namespace std;

class Collection
{
    public:
                Collection();
                Collection( const Collection & );
            virtual ~Collection()=0;
            virtual bool add(const int x) =0;
            virtual int& remove() = 0; 
            virtual Collection& operator=(const Collection& rhs)=0;
            virtual int& operator[](int index) =0;   
        virtual const int& operator[](int index)const =0; 
        Collection& copy(); 
                int size_();

    protected:

    private:
               int _size;  

}; 
share|improve this question
2  
Do you have a no argument constructor defined for your Base class Collection? Show us the definition of Base class. The statement you have shown is calls the Base class constructor in the initialization list. – Alok Save Apr 24 '12 at 2:39
I have updated the post with info on the base class – Kobojunkie Apr 24 '12 at 2:43
3  
Have you defined Collection()? This is my best guess about your problem at the moment. – Alok Save Apr 24 '12 at 2:44
To put it plainly, your Collection() constructor needs a body. If it has one, the linker isn't finding it. – chris Apr 24 '12 at 2:47
Thanks! That seemed to have been the problem. I would not have guessed that at all. – Kobojunkie Apr 24 '12 at 2:54
show 1 more comment

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.