From: fjh AT cs DOT mu DOT OZ DOT AU (Fergus Henderson) Subject: Re: Missing virtual functions 2 Sep 1997 01:38:43 -0700 Sender: mail AT cygnus DOT com Approved: cygnus DOT gnu-win32 AT cygnus DOT com Distribution: cygnus Message-ID: <199709010253.MAA26759.cygnus.gnu-win32@mundook.cs.mu.OZ.AU> References: <33FF524B DOT 7B256D82 AT uci DOT edu> Original-To: ebritten AT uci DOT edu Original-Cc: gnu-win32 AT cygnus DOT com Original-Sender: owner-gnu-win32 AT cygnus DOT com This is an off-topic answer to an off-topic question about GNU C++. Eric Britten writes: >Yesterday I found that if one declares virtual functions in a class >like: > >class A >{ > A(); > virtual void B(); >}; > >and the definitions for the functions(inline or external) are not found >by the linker then two types of linking errors result. > >1. Undefined reference to a vtable in the constructors of the class. >2. Undefined reference to any other inline functions of the class that >are used by other code. > >It took me a while to figure out that if all virtual functions are >defined, then these errors go away. Is this GNU specific? The exact error messages you get are probably specific to GNU C++. However, the fact that you do get errors if virtual functions are not defined is not GNU specific. The GNU behaviour conforms to the draft ANSI/ISO C++ standard, which says that programs must contain a definition of every virtual function. (Implementations are not _required_ to diagnose this error, however, so such code _may_ work on other compilers...) -- Fergus Henderson | "I have always known that the pursuit WWW: | of excellence is a lethal habit" PGP: finger fjh AT 128 DOT 250 DOT 37 DOT 3 | -- the last words of T. S. Garp. - For help on using this list (especially unsubscribing), send a message to "gnu-win32-request AT cygnus DOT com" with one line of text: "help".