Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/jpa/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 对“vtable for stations::baseStation';_C++ - Fatal编程技术网

C++ 对“vtable for stations::baseStation';

C++ 对“vtable for stations::baseStation';,c++,C++,可能重复: 我不知怎的犯了这个错误。这是我的代码: #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(do

可能重复:

我不知怎的犯了这个错误。这是我的代码:

#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;
};
\ifndef基站_
#定义基站_
#包括
#包括“Song.h”
#包括
使用mtm::Song;
使用std::list;
名称空间站{
类基站{
公众:
显式基站(双频):频率(频率){}
双getFrequency()常量;
bool getIsFullVersion()常量;
布尔isInPlaylist(常量字符串和作者、常量字符串和名称)常量;
虚拟空添加歌曲(const歌曲和歌曲);
虚拟常量歌曲&getCurrentSong()常量;
虚拟常量SongPart&getCurrentlyPlayedPart(无符号整数时间)常量;
虚拟基站();
私人:
//是否对其进行保护??
双频;
列表播放列表;
列表::迭代器currentSong;
布尔是完整版本;
};
我得到的错误是:在“explicit”行中未定义对“vtable for stations::baseStation”的引用


非常感谢。`

你在这里发布的代码很好。通过定义我自己的Song和SongPart类,我可以毫无问题地编译它(因为它们是在Song.h中定义的)


我假设你的“Song.h”做了一些不寻常的事情。

这是链接器错误吗

当编译器在*.cpp文件中找不到任何虚拟成员定义时(例如,如果已内联定义所有虚拟函数),可能会发生此错误。链接器无法找到要在哪个对象文件中为类生成虚拟指针表,因为任何源文件中均未定义任何虚拟函数,并且将生成此错误消息。
解决方案是在cpp文件中至少定义一个虚拟成员。

此问题有很多重复项,请确保在询问之前进行搜索。您可以查看右侧的“相关”栏。您是否在某处定义了您的函数?