On Wed, 23 Jun 2004 12:58:36 +0200, "Marcin Kalicinski"
<kalita@poczta.onet.pl> wrote:
[color=blue]
>Hi,
>
>In the following code example:
>
>class Base {
> virtual void CopyFrom(const Base *);
>};
>
>class Derived: public Base {
> void CopyFrom(const Derived *);
>};
>
>Derived::CopyFrom() does not override Base::CopyFrom() (am I right?)
>What should I do if I want this kind of method in hierarchy to be virtual?
>Do I have to change the signature of CopyFrom in Derived to
>
>void Derived::CopyFrom(const Base *)
>
>And do a compile time check if supplied pointer is of Derived class by using
>dynamic_cast?[/color]
That would be one way of doing it. In fact, it's probably the only way
that makes sense. For example, A<--B and A<--C. What does it mean to
copy B from C? Or C from B? Do you want to allow this?
There was a similar thread recently in this NG called "Problem with
overriden operators" which you might find interesting.
--
Bob Hairgrove
NoSpamPlease@Home.com