-1

I am a complete beginner and I have read a variety of posts on the forum regarding this subject, yet I am still unsure of where I am going wrong.

This is my base class:

class room {
    protected:
        int doors;
        string name;
        room *north;
        room *east;
        room *south;
        room *west;

    public:
        room(int numDoors, string rmName);
        virtual string getName();
        virtual void setRoom(int numDoors, string rmName);
        void setConnect(room *room1, room *room2, room *room3, room *room4);
};

room::room(int numDoors, string rmName) : doors(numDoors), name(rmName) {}

string room::getName() {
    return this->name;
}

void room::setConnect(room *room1, room *room2, room *room3, room *room4) {
    this->north = room1;
    this->east = room2;
    this->south = room3;
    this->west = room4;
    return;
}

And this is my derived class:

class treasureRoom : public room {
    protected:
        string chest[5];

    public:
        treasureRoom() : base(4, "The Mad King's Hoard") {}
        void setChest(string &loot1, string &loot2, string &loot3, string &loot4, string &loot5);
        string getChest(int i);
};


void treasureRoom::setChest(string &loot1, string &loot2, string &loot3, string &loot4, string &loot5) {
    this->chest[0] = loot1;
    this->chest[1] = loot2;
    this->chest[2] = loot3;
    this->chest[3] = loot4;
    this->chest[4] = loot5;
    return;
}

string treasureRoom::getChest(int i) {
    return this->chest[i];
}

I have attempted several times to implement solutions talked about on the forums regarding this type of error, but I am still missing something of key importance. Any help would be appreciated!

Re Captcha
  • 3,125
  • 2
  • 22
  • 34

1 Answers1

1

The full error message is pretty clear about what is going on:

Undefined symbols for architecture x86_64:
  "room::setRoom(int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)", referenced from:
      vtable for room in asd-cc336a.o
      vtable for treasureRoom in asd-cc336a.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [asd] Error 1

You didn't include a definition for room::setRoom(...).

Bill Lynch
  • 80,138
  • 16
  • 128
  • 173