Path: utzoo!attcan!ncrcan!scocan!jfischer From: jfischer@sco.COM (Jonathan Fischer) Newsgroups: comp.lang.c++ Subject: Re: polymorfism on objects, not pointers Summary: Fixed in 2.1 Keywords: polymorfism dynamic binding Message-ID: <1990Jul6.151916.3993@sco.COM> Date: 6 Jul 90 19:19:16 GMT References: <631@atcmpe.atcmp.nl> Reply-To: jfischer@sco.COM (Jonathan Fischer) Organization: SCO Canada, Inc. (formerly HCR Corporation) Lines: 31 leo@atcmp.nl (Leo Willems) writes: >In the example below ::g() accepts a class B variable (not a pointer/reference) >If g() is called with a D (derived from B) the virtual mechanism works! > B bb; > D dd; > g(dd); //see end of posting for complete code >In C++ 1.2 this didn't work (compile time error: can not make a B from a D) >but in 2.0 it is possible to make a B from a D but as I understand it that >should not alter the B behaviour, and so no runtime binding is expected. >[etc.] The behaviour has changed in cfront 2.1; namely, with the following calls, g(bb); g(dd); the output is fb() fb(). When the parameter is a reference or a pointer, however, the appropriate virtual function is called. -- Jonathan Fischer SCO Canada, Inc. Toronto, Ontario, Canada Usenet's first law of Flamodynamics: For every opinion, there is an equal and opposite counter-opinion.