我在Protocal.h文件中编写了一个类。
#ifndef PROTOCOL_H
#define PROTOCOL_H
class Protocol{
public:
Protocol();
void analyse();
};
Protocol::Protocol() {}
void Protocol::analyse() {
}
#endif // PROTOCOL_H在sinffer.h文件中,我使用这个头文件

当我构建这个项目时,有一些错误,我不知道为什么。

在我的.pro文件中

这里只写一次协议.h文件。
发布于 2016-06-04 08:37:55
您可以使用以下方式定义协议构造器的主体:
在类定义中(隐式内联)
// protocol.h
class Protocol {
public:
Protocol() {
// in the class definition
}
...
};显式内联
// protocol.h
class Protocol {
public:
Protocol();
...
};
//
inline Protocol::Protocol() {
// inline prevents double definition error when you include protocol.h
}放入cpp文件
// protocol.h
class Protocol {
public:
Protocol();
...
};
// protocol.cpp
#include "protocol.h"
Protocol::Protocol() {
}https://stackoverflow.com/questions/37627768
复制相似问题