Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!waikato.ac.nz!aukuni.ac.nz!gkean From: gkean@ccu1.aukuni.ac.nz (Graham Kean;;g_kean) Newsgroups: comp.lang.c++ Subject: Static initialization Summary: Problem with statically initializing instance with virtual funcs Keywords: static initialize virtual Message-ID: <1991May10.063358.15955@ccu1.aukuni.ac.nz> Date: 10 May 91 06:33:58 GMT Organization: University of Auckland, New Zealand. Lines: 19 Can anyone tell me why it is not possible to statically initialize an instance of a class containing virtual functions? Both Zortech C++ and Borland C++ give an error at the '{1,2,3}' in the following example: class TESTCLASS { public: int a,b,c; virtual void testfunc(); }; void TESTCLASS::testfunc() {} TESTCLASS test = {1,2,3}; I realize that there will be a 'hidden' instance variable, being a pointer to the virtual function table, but I can't quite grasp why the compiler can't generate it. (The example works fine when testfunc() is not virtual).