C++ 未能编译c++;代码未定义对“vtable”的引用
我正在尝试创建一个stomp客户端来处理来自服务器的消息。 为了做到这一点,我使用访客访问客户端 我不断得到“未定义的对'vtable for StompConnected'的引用” (以及扩展StompServerFrame的每个类) 代码如下: /////////////StompFrame.h///////////////C++ 未能编译c++;代码未定义对“vtable”的引用,c++,C++,我正在尝试创建一个stomp客户端来处理来自服务器的消息。 为了做到这一点,我使用访客访问客户端 我不断得到“未定义的对'vtable for StompConnected'的引用” (以及扩展StompServerFrame的每个类) 代码如下: /////////////StompFrame.h/////////////// #ifndef STOMPFRAME_H_ #define STOMPFRAME_H_ #include <string> #include <ss
#ifndef STOMPFRAME_H_
#define STOMPFRAME_H_
#include <string>
#include <sstream>
#include <map>
using namespace std;
class StompFrame{
private:
const string _command;
protected:
map<string, string> _headers;
string _content;
StompFrame(string command);
public:
static const char END_OF_MESSAGE = 0;
string toString() const;
void addHeader(string header, string value);
bool getHeader(string header, string& value);
void setContent(string content);
~StompFrame();
};
#endif
#ifndef STOMPSERVERFRAME_H_
#define STOMPSERVERFRAME_H_
#include "StompFrame.h"
#include "MessageProcessor.h"
class MessageProcessor;
class StompServerFrame: public StompFrame{
protected:
StompServerFrame(string command);
public:
virtual ~StompServerFrame();
virtual void accept(MessageProcessor& processor) = 0;
};
#endif
#ifndef STOMPCONNECTED_H_
#define STOMPCONNECTED_H_
#include "StompServerFrame.h"
class StompConnected: public StompServerFrame{
private:
string _version;
public:
static const string COMMAND_NAME;
StompConnected(string version);
virtual ~StompConnected();
virtual void accept(MessageProcessor& processor);
};
#endif
#ifndef MESSAGEPROCESSOR_H_
#define MESSAGEPROCESSOR_H_
class StompServerFrame;
class StompConnected;
class StompError;
class StompReceipt;
class StompMessage;
class MessageProcessor{
public:
void processMessage(StompServerFrame* frame);
void processMessage(StompConnected* frame);
void processMessage(StompError* frame);
void processMessage(StompReceipt* frame);
void processMessage(StompMessage* frame);
};
#endif
#include "../include/StompFrame.h"
#include <iostream>
#include <string>
using namespace std;
StompFrame::StompFrame(string command):_command(command), _headers(), _content(){}
StompFrame::~StompFrame(){}
string StompFrame::toString() const{
stringstream stream;
stream<<_command<<endl;
for(map<string, string>::const_iterator iterator = _headers.begin(); iterator != _headers.end(); iterator++){
string header = (*iterator).first;
string value = (*iterator).second;
stream<<header<<":"<<value<<endl;
}
stream<<endl;
stream<<_content;
if (_content != ""){
stream<<endl;
}
stream<<END_OF_MESSAGE;
return stream.str();
}
void StompFrame::addHeader(string header, string value){
_headers[header] = value;
}
bool StompFrame::getHeader(string header, string& value){
map<string, string>::iterator iterator = _headers.find(header);
if (iterator == _headers.end()){
return false;
}
value = (*iterator).second;
return true;
}
void StompFrame::setContent(string content){
_content = content;
}
#include "../include/StompServerFrame.h"
StompServerFrame::StompServerFrame(string command):StompFrame(command){}
StompServerFrame::~StompServerFrame(){}
#include "../include/StompConnected.h"
StompConnected::StompConnected(string version): StompServerFrame(StompConnected::COMMAND_NAME),
_version("version"){
_headers[_version] = version;
}
void StompConnected::accept(MessageProcessor& processor){
processor.processMessage(this);
}
const string StompConnected::COMMAND_NAME = "CONNECTED";
#include "../include/MessageProcessor.h"
#include "../include/StompServerFrame.h"
#include "../include/StompConnected.h"
#include "../include/StompError.h"
#include "../include/StompReceipt.h"
#include "../include/StompMessage.h"
void MessageProcessor::processMessage(StompServerFrame* frame){
frame->accept(*this);
}
//////////////stomph//////////////////
#ifndef STOMPFRAME_H_
#define STOMPFRAME_H_
#include <string>
#include <sstream>
#include <map>
using namespace std;
class StompFrame{
private:
const string _command;
protected:
map<string, string> _headers;
string _content;
StompFrame(string command);
public:
static const char END_OF_MESSAGE = 0;
string toString() const;
void addHeader(string header, string value);
bool getHeader(string header, string& value);
void setContent(string content);
~StompFrame();
};
#endif
#ifndef STOMPSERVERFRAME_H_
#define STOMPSERVERFRAME_H_
#include "StompFrame.h"
#include "MessageProcessor.h"
class MessageProcessor;
class StompServerFrame: public StompFrame{
protected:
StompServerFrame(string command);
public:
virtual ~StompServerFrame();
virtual void accept(MessageProcessor& processor) = 0;
};
#endif
#ifndef STOMPCONNECTED_H_
#define STOMPCONNECTED_H_
#include "StompServerFrame.h"
class StompConnected: public StompServerFrame{
private:
string _version;
public:
static const string COMMAND_NAME;
StompConnected(string version);
virtual ~StompConnected();
virtual void accept(MessageProcessor& processor);
};
#endif
#ifndef MESSAGEPROCESSOR_H_
#define MESSAGEPROCESSOR_H_
class StompServerFrame;
class StompConnected;
class StompError;
class StompReceipt;
class StompMessage;
class MessageProcessor{
public:
void processMessage(StompServerFrame* frame);
void processMessage(StompConnected* frame);
void processMessage(StompError* frame);
void processMessage(StompReceipt* frame);
void processMessage(StompMessage* frame);
};
#endif
#include "../include/StompFrame.h"
#include <iostream>
#include <string>
using namespace std;
StompFrame::StompFrame(string command):_command(command), _headers(), _content(){}
StompFrame::~StompFrame(){}
string StompFrame::toString() const{
stringstream stream;
stream<<_command<<endl;
for(map<string, string>::const_iterator iterator = _headers.begin(); iterator != _headers.end(); iterator++){
string header = (*iterator).first;
string value = (*iterator).second;
stream<<header<<":"<<value<<endl;
}
stream<<endl;
stream<<_content;
if (_content != ""){
stream<<endl;
}
stream<<END_OF_MESSAGE;
return stream.str();
}
void StompFrame::addHeader(string header, string value){
_headers[header] = value;
}
bool StompFrame::getHeader(string header, string& value){
map<string, string>::iterator iterator = _headers.find(header);
if (iterator == _headers.end()){
return false;
}
value = (*iterator).second;
return true;
}
void StompFrame::setContent(string content){
_content = content;
}
#include "../include/StompServerFrame.h"
StompServerFrame::StompServerFrame(string command):StompFrame(command){}
StompServerFrame::~StompServerFrame(){}
#include "../include/StompConnected.h"
StompConnected::StompConnected(string version): StompServerFrame(StompConnected::COMMAND_NAME),
_version("version"){
_headers[_version] = version;
}
void StompConnected::accept(MessageProcessor& processor){
processor.processMessage(this);
}
const string StompConnected::COMMAND_NAME = "CONNECTED";
#include "../include/MessageProcessor.h"
#include "../include/StompServerFrame.h"
#include "../include/StompConnected.h"
#include "../include/StompError.h"
#include "../include/StompReceipt.h"
#include "../include/StompMessage.h"
void MessageProcessor::processMessage(StompServerFrame* frame){
frame->accept(*this);
}
//////////////////////////StompFrame.cpp///////////////////////////////
#ifndef STOMPFRAME_H_
#define STOMPFRAME_H_
#include <string>
#include <sstream>
#include <map>
using namespace std;
class StompFrame{
private:
const string _command;
protected:
map<string, string> _headers;
string _content;
StompFrame(string command);
public:
static const char END_OF_MESSAGE = 0;
string toString() const;
void addHeader(string header, string value);
bool getHeader(string header, string& value);
void setContent(string content);
~StompFrame();
};
#endif
#ifndef STOMPSERVERFRAME_H_
#define STOMPSERVERFRAME_H_
#include "StompFrame.h"
#include "MessageProcessor.h"
class MessageProcessor;
class StompServerFrame: public StompFrame{
protected:
StompServerFrame(string command);
public:
virtual ~StompServerFrame();
virtual void accept(MessageProcessor& processor) = 0;
};
#endif
#ifndef STOMPCONNECTED_H_
#define STOMPCONNECTED_H_
#include "StompServerFrame.h"
class StompConnected: public StompServerFrame{
private:
string _version;
public:
static const string COMMAND_NAME;
StompConnected(string version);
virtual ~StompConnected();
virtual void accept(MessageProcessor& processor);
};
#endif
#ifndef MESSAGEPROCESSOR_H_
#define MESSAGEPROCESSOR_H_
class StompServerFrame;
class StompConnected;
class StompError;
class StompReceipt;
class StompMessage;
class MessageProcessor{
public:
void processMessage(StompServerFrame* frame);
void processMessage(StompConnected* frame);
void processMessage(StompError* frame);
void processMessage(StompReceipt* frame);
void processMessage(StompMessage* frame);
};
#endif
#include "../include/StompFrame.h"
#include <iostream>
#include <string>
using namespace std;
StompFrame::StompFrame(string command):_command(command), _headers(), _content(){}
StompFrame::~StompFrame(){}
string StompFrame::toString() const{
stringstream stream;
stream<<_command<<endl;
for(map<string, string>::const_iterator iterator = _headers.begin(); iterator != _headers.end(); iterator++){
string header = (*iterator).first;
string value = (*iterator).second;
stream<<header<<":"<<value<<endl;
}
stream<<endl;
stream<<_content;
if (_content != ""){
stream<<endl;
}
stream<<END_OF_MESSAGE;
return stream.str();
}
void StompFrame::addHeader(string header, string value){
_headers[header] = value;
}
bool StompFrame::getHeader(string header, string& value){
map<string, string>::iterator iterator = _headers.find(header);
if (iterator == _headers.end()){
return false;
}
value = (*iterator).second;
return true;
}
void StompFrame::setContent(string content){
_content = content;
}
#include "../include/StompServerFrame.h"
StompServerFrame::StompServerFrame(string command):StompFrame(command){}
StompServerFrame::~StompServerFrame(){}
#include "../include/StompConnected.h"
StompConnected::StompConnected(string version): StompServerFrame(StompConnected::COMMAND_NAME),
_version("version"){
_headers[_version] = version;
}
void StompConnected::accept(MessageProcessor& processor){
processor.processMessage(this);
}
const string StompConnected::COMMAND_NAME = "CONNECTED";
#include "../include/MessageProcessor.h"
#include "../include/StompServerFrame.h"
#include "../include/StompConnected.h"
#include "../include/StompError.h"
#include "../include/StompReceipt.h"
#include "../include/StompMessage.h"
void MessageProcessor::processMessage(StompServerFrame* frame){
frame->accept(*this);
}
/////////////////StompConnected.cpp////////////////////
#ifndef STOMPFRAME_H_
#define STOMPFRAME_H_
#include <string>
#include <sstream>
#include <map>
using namespace std;
class StompFrame{
private:
const string _command;
protected:
map<string, string> _headers;
string _content;
StompFrame(string command);
public:
static const char END_OF_MESSAGE = 0;
string toString() const;
void addHeader(string header, string value);
bool getHeader(string header, string& value);
void setContent(string content);
~StompFrame();
};
#endif
#ifndef STOMPSERVERFRAME_H_
#define STOMPSERVERFRAME_H_
#include "StompFrame.h"
#include "MessageProcessor.h"
class MessageProcessor;
class StompServerFrame: public StompFrame{
protected:
StompServerFrame(string command);
public:
virtual ~StompServerFrame();
virtual void accept(MessageProcessor& processor) = 0;
};
#endif
#ifndef STOMPCONNECTED_H_
#define STOMPCONNECTED_H_
#include "StompServerFrame.h"
class StompConnected: public StompServerFrame{
private:
string _version;
public:
static const string COMMAND_NAME;
StompConnected(string version);
virtual ~StompConnected();
virtual void accept(MessageProcessor& processor);
};
#endif
#ifndef MESSAGEPROCESSOR_H_
#define MESSAGEPROCESSOR_H_
class StompServerFrame;
class StompConnected;
class StompError;
class StompReceipt;
class StompMessage;
class MessageProcessor{
public:
void processMessage(StompServerFrame* frame);
void processMessage(StompConnected* frame);
void processMessage(StompError* frame);
void processMessage(StompReceipt* frame);
void processMessage(StompMessage* frame);
};
#endif
#include "../include/StompFrame.h"
#include <iostream>
#include <string>
using namespace std;
StompFrame::StompFrame(string command):_command(command), _headers(), _content(){}
StompFrame::~StompFrame(){}
string StompFrame::toString() const{
stringstream stream;
stream<<_command<<endl;
for(map<string, string>::const_iterator iterator = _headers.begin(); iterator != _headers.end(); iterator++){
string header = (*iterator).first;
string value = (*iterator).second;
stream<<header<<":"<<value<<endl;
}
stream<<endl;
stream<<_content;
if (_content != ""){
stream<<endl;
}
stream<<END_OF_MESSAGE;
return stream.str();
}
void StompFrame::addHeader(string header, string value){
_headers[header] = value;
}
bool StompFrame::getHeader(string header, string& value){
map<string, string>::iterator iterator = _headers.find(header);
if (iterator == _headers.end()){
return false;
}
value = (*iterator).second;
return true;
}
void StompFrame::setContent(string content){
_content = content;
}
#include "../include/StompServerFrame.h"
StompServerFrame::StompServerFrame(string command):StompFrame(command){}
StompServerFrame::~StompServerFrame(){}
#include "../include/StompConnected.h"
StompConnected::StompConnected(string version): StompServerFrame(StompConnected::COMMAND_NAME),
_version("version"){
_headers[_version] = version;
}
void StompConnected::accept(MessageProcessor& processor){
processor.processMessage(this);
}
const string StompConnected::COMMAND_NAME = "CONNECTED";
#include "../include/MessageProcessor.h"
#include "../include/StompServerFrame.h"
#include "../include/StompConnected.h"
#include "../include/StompError.h"
#include "../include/StompReceipt.h"
#include "../include/StompMessage.h"
void MessageProcessor::processMessage(StompServerFrame* frame){
frame->accept(*this);
}
//////////////////////MessageProcessor.cpp//////////////////
#ifndef STOMPFRAME_H_
#define STOMPFRAME_H_
#include <string>
#include <sstream>
#include <map>
using namespace std;
class StompFrame{
private:
const string _command;
protected:
map<string, string> _headers;
string _content;
StompFrame(string command);
public:
static const char END_OF_MESSAGE = 0;
string toString() const;
void addHeader(string header, string value);
bool getHeader(string header, string& value);
void setContent(string content);
~StompFrame();
};
#endif
#ifndef STOMPSERVERFRAME_H_
#define STOMPSERVERFRAME_H_
#include "StompFrame.h"
#include "MessageProcessor.h"
class MessageProcessor;
class StompServerFrame: public StompFrame{
protected:
StompServerFrame(string command);
public:
virtual ~StompServerFrame();
virtual void accept(MessageProcessor& processor) = 0;
};
#endif
#ifndef STOMPCONNECTED_H_
#define STOMPCONNECTED_H_
#include "StompServerFrame.h"
class StompConnected: public StompServerFrame{
private:
string _version;
public:
static const string COMMAND_NAME;
StompConnected(string version);
virtual ~StompConnected();
virtual void accept(MessageProcessor& processor);
};
#endif
#ifndef MESSAGEPROCESSOR_H_
#define MESSAGEPROCESSOR_H_
class StompServerFrame;
class StompConnected;
class StompError;
class StompReceipt;
class StompMessage;
class MessageProcessor{
public:
void processMessage(StompServerFrame* frame);
void processMessage(StompConnected* frame);
void processMessage(StompError* frame);
void processMessage(StompReceipt* frame);
void processMessage(StompMessage* frame);
};
#endif
#include "../include/StompFrame.h"
#include <iostream>
#include <string>
using namespace std;
StompFrame::StompFrame(string command):_command(command), _headers(), _content(){}
StompFrame::~StompFrame(){}
string StompFrame::toString() const{
stringstream stream;
stream<<_command<<endl;
for(map<string, string>::const_iterator iterator = _headers.begin(); iterator != _headers.end(); iterator++){
string header = (*iterator).first;
string value = (*iterator).second;
stream<<header<<":"<<value<<endl;
}
stream<<endl;
stream<<_content;
if (_content != ""){
stream<<endl;
}
stream<<END_OF_MESSAGE;
return stream.str();
}
void StompFrame::addHeader(string header, string value){
_headers[header] = value;
}
bool StompFrame::getHeader(string header, string& value){
map<string, string>::iterator iterator = _headers.find(header);
if (iterator == _headers.end()){
return false;
}
value = (*iterator).second;
return true;
}
void StompFrame::setContent(string content){
_content = content;
}
#include "../include/StompServerFrame.h"
StompServerFrame::StompServerFrame(string command):StompFrame(command){}
StompServerFrame::~StompServerFrame(){}
#include "../include/StompConnected.h"
StompConnected::StompConnected(string version): StompServerFrame(StompConnected::COMMAND_NAME),
_version("version"){
_headers[_version] = version;
}
void StompConnected::accept(MessageProcessor& processor){
processor.processMessage(this);
}
const string StompConnected::COMMAND_NAME = "CONNECTED";
#include "../include/MessageProcessor.h"
#include "../include/StompServerFrame.h"
#include "../include/StompConnected.h"
#include "../include/StompError.h"
#include "../include/StompReceipt.h"
#include "../include/StompMessage.h"
void MessageProcessor::processMessage(StompServerFrame* frame){
frame->accept(*this);
}
/////////////////////////////////////////////////////////////////
#ifndef STOMPFRAME_H_
#define STOMPFRAME_H_
#include <string>
#include <sstream>
#include <map>
using namespace std;
class StompFrame{
private:
const string _command;
protected:
map<string, string> _headers;
string _content;
StompFrame(string command);
public:
static const char END_OF_MESSAGE = 0;
string toString() const;
void addHeader(string header, string value);
bool getHeader(string header, string& value);
void setContent(string content);
~StompFrame();
};
#endif
#ifndef STOMPSERVERFRAME_H_
#define STOMPSERVERFRAME_H_
#include "StompFrame.h"
#include "MessageProcessor.h"
class MessageProcessor;
class StompServerFrame: public StompFrame{
protected:
StompServerFrame(string command);
public:
virtual ~StompServerFrame();
virtual void accept(MessageProcessor& processor) = 0;
};
#endif
#ifndef STOMPCONNECTED_H_
#define STOMPCONNECTED_H_
#include "StompServerFrame.h"
class StompConnected: public StompServerFrame{
private:
string _version;
public:
static const string COMMAND_NAME;
StompConnected(string version);
virtual ~StompConnected();
virtual void accept(MessageProcessor& processor);
};
#endif
#ifndef MESSAGEPROCESSOR_H_
#define MESSAGEPROCESSOR_H_
class StompServerFrame;
class StompConnected;
class StompError;
class StompReceipt;
class StompMessage;
class MessageProcessor{
public:
void processMessage(StompServerFrame* frame);
void processMessage(StompConnected* frame);
void processMessage(StompError* frame);
void processMessage(StompReceipt* frame);
void processMessage(StompMessage* frame);
};
#endif
#include "../include/StompFrame.h"
#include <iostream>
#include <string>
using namespace std;
StompFrame::StompFrame(string command):_command(command), _headers(), _content(){}
StompFrame::~StompFrame(){}
string StompFrame::toString() const{
stringstream stream;
stream<<_command<<endl;
for(map<string, string>::const_iterator iterator = _headers.begin(); iterator != _headers.end(); iterator++){
string header = (*iterator).first;
string value = (*iterator).second;
stream<<header<<":"<<value<<endl;
}
stream<<endl;
stream<<_content;
if (_content != ""){
stream<<endl;
}
stream<<END_OF_MESSAGE;
return stream.str();
}
void StompFrame::addHeader(string header, string value){
_headers[header] = value;
}
bool StompFrame::getHeader(string header, string& value){
map<string, string>::iterator iterator = _headers.find(header);
if (iterator == _headers.end()){
return false;
}
value = (*iterator).second;
return true;
}
void StompFrame::setContent(string content){
_content = content;
}
#include "../include/StompServerFrame.h"
StompServerFrame::StompServerFrame(string command):StompFrame(command){}
StompServerFrame::~StompServerFrame(){}
#include "../include/StompConnected.h"
StompConnected::StompConnected(string version): StompServerFrame(StompConnected::COMMAND_NAME),
_version("version"){
_headers[_version] = version;
}
void StompConnected::accept(MessageProcessor& processor){
processor.processMessage(this);
}
const string StompConnected::COMMAND_NAME = "CONNECTED";
#include "../include/MessageProcessor.h"
#include "../include/StompServerFrame.h"
#include "../include/StompConnected.h"
#include "../include/StompError.h"
#include "../include/StompReceipt.h"
#include "../include/StompMessage.h"
void MessageProcessor::processMessage(StompServerFrame* frame){
frame->accept(*this);
}
请告诉我
谢谢!您错过了
virtual ~StompConnected();
您错过了的实现
virtual ~StompConnected();