Topic: virtual functions return different types
Author: Alexander Krotoff <krotoff@such.srcc.msu.su>
Date: 1996/07/01 Raw View
Hello, c++ gurus,
In the April'95 WP it is allowed to have virtual function
overriden with the different return type.
10.3 Virtual functions:
p5 A program is ill-formed if the return type of any overriding function
differs from the return type of the overridden function unless the
return type of the latter is pointer or reference (possibly cv-
qualified) to a class B, and the return type of the former is pointer
or reference (respectively) to a class D such that B is an unambiguous
direct or indirect base class of D, accessible in the class of the
overriding function, and the cv-qualification in the return type of
the overriding function is less than or equal to the cv-qualification
in the return type of the overridden function.
This technique cannot be derived from the c++ rtti, since this paragraph
says nothing about base class B. To use rtti we shall have polymorphic
base class. How this rule may be implemented ?
--
Alexander N. Krotoff
Research Computer Center
Moscow State University
---
[ comp.std.c++ is moderated. To submit articles: Try just posting with your
newsreader. If that fails, use mailto:std-c++@ncar.ucar.edu
comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
Comments? mailto:std-c++-request@ncar.ucar.edu
]
Author: stew@datalytics.com (Rob Stewart)
Date: 1996/07/01 Raw View
In article <199607011021.NAA19794@such.srcc.msu.su>, Alexander Krotoff
<krotoff@such.srcc.msu.su> wrote:
>In the April'95 WP it is allowed to have virtual function
>overriden with the different return type.
>
>10.3 Virtual functions:
>
>p5 A program is ill-formed if the return type of any overriding
> function differs from the return type of the overridden function
> unless the return type of the latter is pointer or reference
> (possibly cv-qualified) to a class B, and the return type of the
> former is pointer or reference (respectively) to a class D such
> that B is an unambiguous direct or indirect base class of D,
> accessible in the class of the overriding function, and the
> cv-qualification in the return type of the overriding function is
> less than or equal to the cv-qualification in the return type of
> the overridden function.
>
>This technique cannot be derived from the c++ rtti, since this paragraph
>says nothing about base class B. To use rtti we shall have polymorphic
>base class. How this rule may be implemented ?
Since D is overriding a function in B, that function must have
been declared virtual in B. "Overriding" is reserved for virtual
functions. "Overloading" need not refer to virtual functions, it
simply implies varying argument lists. Given, then, the implied
virtual behavior of the function, RTTI is also possible.
Robert Stewart | My opinions are usually my own.
Datalytics, Inc. | stew@datalytics.com
| http://www.datalytics.com
---
[ comp.std.c++ is moderated. To submit articles: try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]