Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!cs.utexas.edu!uunet!rocket!dove From: dove@rocket.UUCP (Webster Dove) Newsgroups: comp.lang.c++ Subject: abstract class constructor pitfall Message-ID: Date: 6 Jun 89 14:39:05 GMT Sender: news@rocket.UUCP Distribution: comp Organization: Sanders Advanced Technology Dept. Lines: 30 Posting-Front-End: GNU Emacs 18.44.4 of Tue May 12 1987 on rocket (berkeley-unix) The constructor a::a() is booby trapped. Since the virtual mechanism does not work during construction, the attempted call to foo() is undefined. g++-1.35.0 creates an a.out that IOtraps on this. // -*- C++ -*- #include class a { public: virtual void foo() = 0; a() { foo(); } }; class c_a : a { public: virtual void foo() { cout << "c_a\n"; } }; main() { c_a y; } -- Dr. Webster Dove Computing Systems and Architectures Advanced Signal Processing Engineering (ASPEN) Dept. Sanders Associates (a Lockheed Company)