[C++-sig] downcasting problems
Hans Meine
hans_meine at gmx.net
Mon Oct 13 10:03:45 CEST 2008
On Sonntag 28 September 2008, Renato Araujo wrote:
> =======================================
> the python test is this, and this always output "FAIL":
> =======================================
>
> if __name__ == '__main__':
> shape = Shape()
> circle = Circle(shape)
> p = circle.parent()
> if (p == shape):
> print "OK"
> else:
> print "FAIL"
Maybe it's your test which is wrong - you're testing for *identity* (since no
equality comparison operators are defined) of the *python* objects. If you
want to achieve that, using wrappers is one method, using shared_ptrs is
another one AFAICS (but then you wrote "without changing the c++ code").
But anyhow, the p and shape may not satisfy ==, but they'll still "be the same
[c++] object".
--
Ciao, / / .o.
/--/ ..o
/ / ANS ooo
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20081013/16c544d1/attachment.pgp>
More information about the Cplusplus-sig
mailing list