Home Accessibility Courses Twitter The Mouth Facebook Resources Site Map About Us Contact
 
For 2023 (and 2024 ...) - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))
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() {} ;

The complete (working) source code files for this example are available here
(written 2006-07-15, updated 2008-05-04)

Commentatorsays ...
Radha:This really helped me..I wasted a lot of time over that error.
(comment added 2006-07-19 07:00:03)
Associated topics are indexed as below, or enter http://melksh.am/nnnn for individual articles
C234 - C and C based languages - Further C++ Object Oriented features
  [801] Simple polymorphism example - C++ - (2006-07-14)
  [831] Comparison of Object Oriented Philosophy - Python, Java, C++, Perl - (2006-08-13)
  [1159] It can take more that one plus one to get two. - (2007-04-22)
  [1819] Calling base class constructors - (2008-10-03)
  [2004] Variable Scope in C++ - (2009-01-22)
  [2005] Variables and pointers and references - C and C++ - (2009-01-23)
  [2576] What does const mean? C and C++ - (2010-01-15)
  [2673] Multiple Inheritance in C++ - a complete example - (2010-03-12)
  [2717] The Multiple Inheritance Conundrum, interfaces and mixins - (2010-04-11)
  [2849] What are C++ references? Why use them? - (2010-07-02)
  [3057] Lots of things to do with and within a C++ class - (2010-11-16)
  [3069] Strings, Garbage Collection and Variable Scope in C++ - (2010-11-25)
  [3124] C++ - putting the language elements together into a program - (2011-01-08)
  [3238] Bradshaw, Ben and Bill. And some C and C++ pointers and references too. - (2011-04-09)
  [3430] Sigils - the characters on the start of variable names in Perl, Ruby and Fortran - (2011-09-10)
  [3509] Operator Overloading, Exceptions, Pointers, References and Templates in C++ - new examples from our courses - (2011-11-06)
  [3982] Using a vector within an object - C++ - (2013-01-19)
  [4366] Changing what operators do on objects - a comparison across different programming languages - (2014-12-26)
  [4377] Designing a base class and subclasses, and their extension, in C++ - (2015-01-01)
  [4559] When do I use the this keyword in C++? - (2015-10-29)


Back to
Simple polymorphism example - C++
Previous and next
or
Horse's mouth home
Forward to
Not shouting
Some other Articles
Check your user is human. Have him retype a word in a graphic
Melksham Carnival Parade
The Courts, Holt
Not shouting
undefined reference to typeinfo - C++ error message
Effective web campaign?
The case for exceptions
References and Pointers in C++
Writing up new C / C++ notes.
4759 posts, page by page
Link to page ... 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96 at 50 posts per page


This is a page archived from The Horse's Mouth at http://www.wellho.net/horse/ - the diary and writings of Graham Ellis. Every attempt was made to provide current information at the time the page was written, but things do move forward in our business - new software releases, price changes, new techniques. Please check back via our main site for current courses, prices, versions, etc - any mention of a price in "The Horse's Mouth" cannot be taken as an offer to supply at that price.

Link to Ezine home page (for reading).
Link to Blogging home page (to add comments).

Comment: "Had exactly the same problem, with an abstract class, one ..."
Visitor Ranking 5.0 (5=excellent, 1=poor)
1 unpublished comment pending on this page

Comment by Jonas Baeklund (published 2011-02-18)
Had exactly the same problem, with an abstract class, one method missed the =0 [#3884]

Comment by Anon (published 2011-01-16)
Phew. Exact the same problem here. Thanks for the solution. [#3862]

Comment by Anon (published 2010-10-25)
Quickly and easily solved my problem. Thanks Much. [#3809]

Comment by Anon (published 2010-10-08)
You just saved me a lot of time with this page! It was indeed an obscure error message and I appreciate your clear and helpful explanation about what I needed to fix. [Also, your mentioning how weird the error message itself seems made me feel less foolish about having no idea what it was trying to tell me!] Many thanks. [#3802]

You can Add a comment or ranking or edit your own comments
There are presently 1 new comment(s) pending publication on this page

Average page ranking - 5.0

© WELL HOUSE CONSULTANTS LTD., 2024: 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho

PAGE: http://www.wellho.net/mouth/802_unde ... ssage.html • PAGE BUILT: Sun Oct 11 16:07:41 2020 • BUILD SYSTEM: JelliaJamb