Question about C++ references (corrected)

9 views
Skip to first unread message

Charanpal Dhanjal

unread,
Apr 20, 2012, 6:10:55 AM4/20/12
to cython...@googlegroups.com
This is just a corrected version of the mail I sent earlier. Bizarrely
the formatting was totally different to how it was when I was composing
the mail and seemed to include HTML/CSS elements, which made it
difficult to read the code. I hope it's okay now.

---------------------------

I am trying to wrap some C++ code in Cython and am having trouble with
references. Here is a code snippet:

cdef extern from "mapped_matrix_ext.h":
cdef cppclass mapped_matrix_ext[T]:
mapped_matrix_ext(int, int, int)
mapped_matrix_ext[T]& add(mapped_matrix_ext[T]&)

cdef mapped_matrix_ext[double] *A = new mapped_matrix_ext[double](3, 3, 5)
cdef mapped_matrix_ext[double] *B = new mapped_matrix_ext[double](3, 3, 5)
cdef mapped_matrix_ext[double] *C

C = A.add(deref(B))

I get the error "Cannot assign type 'mapped_matrix_ext<double> &' to
'mapped_matrix_ext<double> *'" for the last line which I think means
that I need to find the reference of the value returned by the add
method. I wasn't able to find how to do this in the documentation
however (I think it's meant to be in "Declaring/Using References" which
hasn't yet been written). Could someone please help me out?

Thanks for any help,
Charanpal

Reply all
Reply to author
Forward
0 new messages