博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
undefined reference to typeinfo - C++ error message
阅读量:6945 次
发布时间:2019-06-27

本文共 1380 字,大约阅读时间需要 4 分钟。

undefined reference to typeinfo - C++ error message

There are some compiler and loader error messages that shout obviously as to their cause, but there are others that simply don't give the new user much of an indication as to what's really wrong. And most of those I get to know pretty quickly, so that I can whip around a room during a course, making suggestions to delegate to check for missing ; characters or double quotes, to check that they have used the right type of brackets for a list subscript and haven't unintentionally written a function call, etc.
Here's one of the more obscure messages from the Gnu C++ compiler - or rather from the loader:
g++ -o polygon shape.o circle.o square.o polygon.o
circle.o(.gnu.linkonce.r._ZTI6Circle+0x8): undefined reference to `typeinfo for Shape'
square.o(.gnu.linkonce.r._ZTI6Square+0x8): undefined reference to `typeinfo for Shape'
polygon.o(.gnu.linkonce.t._ZN5ShapeC2Ev+0x8): In function `Shape::Shape()':
: undefined reference to `vtable for Shape'
collect2: ld returned 1 exit status
And you can be scratching you head for hour over that one!
The error? shape.o contains a base class from which classes are derived in circle.o and square.o .. but virtual function(s) in shape's definition are missing null bodies.
The fix? You've got line(s) like
virtual float getarea() ;
that should read
virtual float getarea() {}

这个错误解决了

转载地址:http://uoanl.baihongyu.com/

你可能感兴趣的文章
[jsp学习笔记] jsp基础知识 数据初始化、同步
查看>>
迭代器的使用
查看>>
【noip系列——模拟】玩具谜题
查看>>
js实现获取URL参数
查看>>
js 自定义弹窗方法
查看>>
spring原理案例-基本项目搭建 01 spring framework 下载 官网下载spring jar包
查看>>
使用HttpServletRequestWrapper重写Request请求参数
查看>>
《Android源码设计模式》学习笔记之ImageLoader
查看>>
WPF阴影效果(DropShadowEffect)(转载)
查看>>
第四章~~!!!~switch结构
查看>>
Laravel 实现定时任务
查看>>
Windows安全加固手册
查看>>
“学霸系统”之NABC
查看>>
[WARNING]: Could not match supplied host pattern, ignoring: servers
查看>>
npm install 后缀
查看>>
全自动安装linux操作系统(CentOS)
查看>>
通过自定义域名防止第一代比特币勒索病毒WannaCrypt传播的解决办法
查看>>
LVS负载均衡群集基础(一)
查看>>
fdisk分区命令使用总结
查看>>
HTTP 304 错误的详细解释
查看>>