Path: utzoo!attcan!uunet!rocket!newshost!dove From: dove@batman.uucp (Webster &) Newsgroups: comp.lang.c++ Subject: Will C++ 2.1 fix the virtual function linkage problem? Message-ID: Date: 2 Jun 90 14:29:21 GMT Sender: news@rocket.UUCP Distribution: comp Organization: Lockheed Sanders Inc. Lines: 60 The problem: Suppose a user of a library (e.g. InterViews) has set up many virtual member functions for derived classes that inherit class declarations from the library. Assume that these member functions are being invoked somewhere inside the library that the user is aware of in general, but not in detail. Now assume that a new release of the library comes out and the details of the calling syntax for some of these virtual functions is superficially changed, and the user has not read all the new documentation carefully or the documentation fails to mention the change. This causes the derived class virtual functions to "fail to link" with the base class declarations leading to program failure. There is no compile time warning since the derived virtual declarations are now treated as new function members starting at the derived class level. I have had this happen several times on programs I controlled. I see this as a severe risk. Is this being fixed? I have previously (5/12/87) discussed this issue and I gather it has come up as a recurring theme. I think I have a fix. Since I have not been reading this list for a while, forgive me if it has been discussed. Suppose you allow the derived class to inherit the declaration of the virtual member. class base_class { public: virtual base_virtual(); }; int base_class::base_virtual() { ... default behavior ... } class derived_class : public base_class { } int derived_class::base_virtual() { ... derived behavior ... } This would be back compatible with existing code, not require any new keywords, and allow me to fix my problem with a library line InterViews without requiring any changes to the library. This allows me to explicitly state (by ommision) that I am expecting there to be a matching inherited virtual and would yield a compile time error if that linkage failed. Comments? Web -- Dr. Webster Dove Dr. Webster Dove Experimental Computing Systems ('X') Lockheed Sanders Inc. Signal Processing Center of Technology 144 Daniel Webster Hwy. Lockheed Sanders Inc. Merrimack, NH. 03054 email: .!uunet!rocket!dove (or ) @uunet.uu.net:dove@rocket.uucp