0

Possible Duplicate:
What is an undefined reference/unresolved external symbol error and how do I fix it?

I somehow get this error. This is my code:

#ifndef BASESTATION_H_
#define BASESTATION_H_

#include <list>
#include "Song.h"
#include <string>

using mtm::Song;
using std::list;
namespace stations {

class baseStation {
public:
    explicit baseStation(double frequency) : frequency(frequency) {}
    double getFrequency() const;
    bool getIsFullVersion() const;
    bool isInPlaylist(const string& author, const string& name) const;
    virtual void addSong(const Song& song);
    virtual const Song& getCurrentSong() const;
    virtual const SongPart& getCurrentlyPlayedPart(unsigned int time) const;
    virtual ~baseStation();

private:
    //keep it protected or not??
    double frequency;
    list<Song> playlist;
    list<Song>::iterator currentSong;
    bool isFullVersion;
};

and the error I get is: undefined reference to `vtable for stations::baseStation' on the "explicit" line.

Thanks a lot.`

Community
  • 1
  • 1
dlvhdr
  • 482
  • 4
  • 19

2 Answers2

0

The code you've posted here is fine. I can compile it without issues by defining my own Song and SongPart classes (I have to since they are defined in Song.h).

I'm assuming your "Song.h" is doing something unusual.

Sepand
  • 166
  • 1
0

Is this a linker error ?

This error can occur when the compiler can't find any virtual member definition in a *.cpp file (for example if you have defined all virtual functions inline). The linker can't find out in which object file to generate the virtual pointer table for your class since none of the virtual functions are defined in any source file and will generate this error message. The solution would be to define at least one virtual member in a cpp file.

Hans
  • 56
  • 5