链接错误未定义vtable和typeinfo
Linking errors undefined vtable and typeinfo
我得到这个错误:
Undefined first referenced
symbol in file
typeinfo for Operand Expression_Tree.o
vtable for Operand Expression.o
通过一些谷歌搜索和类似的问题,我发现这可能是因为我如何处理中的虚拟函数(特别是构造函数/析构函数)
class Expression_Tree
{
public:
virtual double evaluate() = 0;
virtual std::string get_postfix() const = 0;
virtual std::string get_infix() const = 0;
virtual std::string str() const = 0;
virtual void print(std::ostream&, int hopCount = 0) const = 0;
virtual Expression_Tree* clone() const = 0;
virtual ~Expression_Tree(){}
protected:
Expression_Tree() {}
Expression_Tree(const Expression_Tree& o) = delete;
Expression_Tree(Expression_Tree&&) = default;
};
有人看到什么不同寻常的东西吗?
正如你们中的一些人在Operand类中所说,问题是它的基。
class Operand : public Expression_Tree
{
public:
Operand& operator=(const Operand&) = default;
Operand& operator=(Operand&&) = default;
// void print(std::ostream&, int hopCount = 0) const; <- this was the problem
std::string get_postfix() const;
std::string get_infix() const;
~Operand() = default;
Operand(const Operand&) = default;
Operand(Operand&&) = default;
protected:
Operand()
: Expression_Tree() {}
};
一旦我删除了void print()
,一切都解决了=)
相关文章:
- 体系结构x86_64的未定义符号:std:terminate(),typeinfo,运算符delete[],运算符new
- OMNeT++:未定义对 'typeinfo for inet::IMobility' 的引用
- 纯虚拟类和错误未定义对 'vtable 的引用
- 对植物的 vtable 的未定义引用?
- 如何查看在程序级别为我的程序创建了多少 vtable 和 vpointer
- 未定义的符号缺少 vtable
- 是否可以在加载RTLD_LOCAL库中合并弱符号,如 vtables/typeinfo?
- 编译器是否会创建vtable,而不考虑在c++中创建对象
- 为什么重复的空基存储不与 vtable 指针重叠?
- 如何在生产中避免vtable查找,并且仍然能够在单元测试中进行广泛的模拟
- 在C中实现vtable而不是使用C++的目的
- 如果使用非公共类,vtable 是否会在二进制文件中持续存在?
- 关于这个在 Linux 上使用 gcc 编译的程序中的 vtable,nm 告诉我什么?
- 使用多个命名空间对 vtable 的未定义引用
- D3D9创建设备,在Alt选项卡后获得vtable黑屏
- 避免对仅在源文件中定义的类发出弱 vtable 警告
- 在C++中声明"interface",而不是将其 vtable 发送到每个翻译单元
- 链接错误未定义vtable和typeinfo
- 对"类的typeinfo"的未定义引用和对"vtable for class"的未定义引用
- 为什么我会被虚拟和具体的课程"Undefined symbols ... typeinfo ... vtable"?