On 24 Jul 2005 21:50:04 -0700, "ectoplasm" <> wrote
in comp.lang.c++:
> The problem is, that MS VC++ gives a compile error
>
> error C2664: cannot convert parameter 1 from 'A *' to 'B *'
>
> on my call DoSomething(pA). Even though pA is a pointer to a B
> instance.
>
> Seems there is no way around this. A method can only take a parameter
> of its type or a derived type. In other words, can only be an
> (implicit) upcast. In my opinion, this is a failure of C++. Don't you
> agree that what I want is not strange at all but is OO functionality
> that naturally should be possible?
No, it is not strange. C++ provides a simple method of doing it,
providing a virtual function in the base class. What is silly is your
arbitrary insistence that you must have functionality but won't use
the standard mechanism that provides it.
--
Jack Klein
Home:
http://JK-Technology.Com
FAQs for
comp.lang.c
http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++
http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html