home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!sunquest!whm
- From: whm@sunquest.UUCP (Bill Mitchell)
- Newsgroups: comp.lang.c++
- Subject: DEC C++ right or wrong on member pointer construct?
- Message-ID: <45110@sunquest.UUCP>
- Date: 29 Jul 92 07:47:51 GMT
- Organization: Sunquest Information Systems, Tucson
- Lines: 49
-
- The following program compiles ok with cfront 2.0 and 2.1, but DEC C++
- complains (at the line marked "error?"):
-
- error: In the initializer for Bpmap[0].Bp::a, "&U::d" is of type "pointer to
- Derived member of U", and may not be converted to "pointer to Base member of U".
-
- class Base {
- };
-
- class Derived: public Base {
- };
-
- class U {
- public:
- Derived d;
- };
-
- struct Bp {
- Base U::*a;
- };
-
- struct Bp Bpmap[] = {
- &U::d, // error?
- 0
- };
-
- It seems to me that it should be ok because the derived class D should
- acceptable in places where the base class B is acceptable.
-
- If I try to cast:
-
- struct Bp Bpmap[] = {
- (Base U::*)&U::d,
- 0
- };
-
- the error is essentially the same:
-
- error: In the initializer for Bpmap[0].Bp::a, "(Base ...)&U::d" is of type
- "pointer to Derived member of U", and may not be converted to "pointer to
- Base member of U".
-
- I welcome your comments.
- --------------------------------------------------------------------
- Bill Mitchell whm@sunquest.com
- Sunquest Information Systems sunquest!whm@arizona.edu
- 4801 E. Broadway {arizona,uunet}!sunquest!whm
- Tucson, AZ, 85711 sunquest!whm@uunet.uu.net
- 602-570-2585
-