On Sat, Jul 09, 2005 at 08:41:47PM +1000, Adam Nielsen wrote: > Hi all, > > I was expecting the following code snippet to work, so am I doing > something wrong, or is there an issue with GCC? I was under the > impression that this is allowed, according to > http://www.parashift.com/c++-faq-lite/strange-inheritance.html#faq-23.1
As you've discovered, FAQ 23.3 gives more detail. > It seems like GCC initially allows it as it starts to compile okay, but > then I get an undefined reference error from the linker (because it > seems to be actually calling Base::number(), which obviously won't work > as it's a pure virtual function.) It's allowed, and will work, but you have to provide a definition for the function. Calling number() from the base constructor calls Base::number() so you have to define it. GOTW 31 discusses topics related to this: http://www.gotw.ca/gotw/031.htm GCC is doing exactly the right thing here, it's not possible to tell that the definition of Base::number() is missing until link time. jon