Path: utzoo!utgpu!news-server.csri.toronto.edu!helios.physics.utoronto.ca!ists!yunexus!hydroesm!jtsv16!torsqnt!geac!alias!earth!rae From: rae@gpu.utcs.toronto.edu (Reid Ellis) Newsgroups: comp.lang.c++ Subject: MPW C++ 1.0b1 warning: changing storage class in virtual methods Summary: MPW CFront 1.0b1 (9/21/89; AT&T 2.0) doesn't issue an error message for changing the storage class of a virtual method Keywords: virtual, static Message-ID: Date: 31 Oct 90 23:09:45 GMT Sender: Reid Ellis Reply-To: Reid Ellis Organization: Alias Research, Inc. Toronto ON Canada Lines: 54 MPW CFront 1.0b1 (9/21/89; AT&T 2.0) does not flag changing the storage class of an overridden virtual method as an error. Executing the resulting code gives bogus values for any parameters reference through the virtual mechanism. Included below is code that illustrates this. #include struct base { virtual int method(int); virtual int virtual_method(int) = 0; private: int qx; }; struct derived : base { static int virtual_method(int); private: static int qvlp; }; int base::method(int v) { int dv = virtual_method(v); cout << form("base::method v is %d and virtual_method(v) is %d\n", v, dv); return v+10; } int derived::virtual_method(int v) { cout << form("derived::virtual_method v is %d\n", v); return v+100; } main() { derived d; d.method(1); d.virtual_method(2); return 0; } // output is as follows: // // derived::virtual_method v is 7365176 // base::method v is 1 and virtual_method(v) is 7365276 // derived::virtual_method v is 2 -- Reid Ellis 264 Broadway Avenue, Toronto ON, M4P 1V9 Canada rae@gpu.utcs.toronto.edu || rae%alias@csri.toronto.edu || +1 416 487 1383