weird error message on dev-cpp

This is a discussion on weird error message on dev-cpp within the C++ Programming forums, part of the General Programming Boards category; im using dev-cpp as my ide and when i try and compile my project that i'm working on it gives ...

  1. #1
    Registered User
    Join Date
    Aug 2005
    Posts
    13

    weird error message on dev-cpp

    im using dev-cpp as my ide and when i try and compile my project that i'm working on it gives me the following error:

    [Linker error] undefined reference to `vtable for ConsItem'

    where consItem is a class in this form:

    Code:
    class ConsItem : 
          public Item {
    public:
    ConsItem(Item &acar, Item &acdr) : car(&acar), cdr(&acdr), Item(Cons) {};
    virtual ~ConsItem() {};
    virtual string toString(); //Turn the Cons item into a string
    private:
    Item *car;
    Item *cdr;
    };
    and the testing code in main like this:

    Code:
    IntegerItem intitem(123);
    StringItem stritem("rocks");
    cout << stritem.toString() << endl;
    cout << intitem.toString() << endl;
        
    ConsItem consitem(intitem, stritem);
    IntegerItem and StringItem and ConsItem all inherit from the same parent class called Item so I assume that i can pass them into ConsItem as Items, maybe i'm wrong? I was wondeirng if anyone else knew what this error means and how to fix it?

  2. #2
    ZuK
    ZuK is offline
    Registered User
    Join Date
    Aug 2005
    Location
    Austria
    Posts
    1,990
    You did not define ConsItem::toString();
    If you want to make ConsItem pure virtual you have to declare it
    Code:
    virtual string toString()=0; //Turn the Cons item into a string
    Kurt

  3. #3
    Registered User
    Join Date
    Aug 2005
    Posts
    13

    true but...

    yeah i should've defined to string but even with that function gone it still is giving the ( [Linker error] undefined reference to `vtable for ConsItem' ) error. I'm really confused what this error is even saying. Anyone with that has used dev-cpp come across this or know where i can find out about this error message?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Weird compiler (Dev)
    By gavra in forum C Programming
    Replies: 11
    Last Post: 08-03-2008, 01:19 AM
  2. strange problem with dev cpp
    By henrychan22 in forum C++ Programming
    Replies: 8
    Last Post: 06-18-2006, 11:05 AM
  3. Multiple Cpp Files
    By w4ck0z in forum C++ Programming
    Replies: 5
    Last Post: 11-14-2005, 01:41 PM
  4. Linker error in Dev Cpp (DX)
    By C+noob in forum Game Programming
    Replies: 2
    Last Post: 08-15-2005, 03:13 AM
  5. dev cpp documentation
    By sanchezero in forum Game Programming
    Replies: 2
    Last Post: 06-18-2002, 02:32 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21