From mboxrd@z Thu Jan 1 00:00:00 1970 From: Joe Buck To: oliva@dcc.unicamp.br (Alexandre Oliva) Cc: jbuck@Synopsys.COM, espie@quatramaran.ens.fr, egcs@egcs.cygnus.com Subject: Re: glossary for egcs - request for contributions Date: Thu, 29 Apr 1999 03:26:00 -0000 Message-id: <199904291024.DAA19602@atrus.synopsys.com> References: X-SW-Source: 1999-04/msg01035.html > > one may replace a class by a derived class. e.g. I can overload a virtual > ^^^^ > make that override > > > typedef int (*PFDerived)(Derived&); > > int bfunc(Base&); > > PFDerived p = &bfunc; > > > this is legal > > No way! :-) Alexandre is right, I was wrong, the C++ language is wrong. (That is, they should have permitted contravariance for regular function pointers, not just member function pointers). > You can't touch types of arguments when casting function types. This > mechanism only works for pointers-to-members: > > struct Base { void foo(); }; > struct Derived : Base {}; > typedef void (Derived::*PFDerived)(); > PFDerived pD = &Base::foo; Correct. Let's pretend I wrote that. :-) From mboxrd@z Thu Jan 1 00:00:00 1970 From: Joe Buck To: oliva@dcc.unicamp.br (Alexandre Oliva) Cc: jbuck@Synopsys.COM, espie@quatramaran.ens.fr, egcs@egcs.cygnus.com Subject: Re: glossary for egcs - request for contributions Date: Fri, 30 Apr 1999 23:15:00 -0000 Message-ID: <199904291024.DAA19602@atrus.synopsys.com> References: X-SW-Source: 1999-04n/msg01044.html Message-ID: <19990430231500.dlOVMNFMJDzQnmkDrStUu4jis0DymzX42ugF2Ez8TuM@z> > > one may replace a class by a derived class. e.g. I can overload a virtual > ^^^^ > make that override > > > typedef int (*PFDerived)(Derived&); > > int bfunc(Base&); > > PFDerived p = &bfunc; > > > this is legal > > No way! :-) Alexandre is right, I was wrong, the C++ language is wrong. (That is, they should have permitted contravariance for regular function pointers, not just member function pointers). > You can't touch types of arguments when casting function types. This > mechanism only works for pointers-to-members: > > struct Base { void foo(); }; > struct Derived : Base {}; > typedef void (Derived::*PFDerived)(); > PFDerived pD = &Base::foo; Correct. Let's pretend I wrote that. :-)