Re: Inheritance

[email protected] (Steffen Mueller)
Newsgroups perl.xs
Message-ID <[email protected]>
Hi Pat,

Pat Dupre wrote:
> I created a C++ class by using XS. Every things OK. Now I want to derive 
> a class
> from it. How can I do it ?

Maybe I'm misunderstanding you, but it should be simple. If you have the 
base Perl class 'Base' that wraps methods in the C++ base class 
'BaseCpp' (separate names for clarity), you can create the Perl class 
'Derived':

package Derived;
use strict; use warnings;
our @ISA = qw(Base);

1;

And write the XS to wrap the new methods in the derived C++ class 
'DerivedCpp' (and put those methods in the Perl Derived namespace). You 
probably need to wrap the derived class' constructor anew.

You may also want to have a look at ExtUtils::XSpp. C++ & XS seems so 
much simpler since I discovered it. The newest release also converts C++ 
exceptions to Perl exceptions in a flexible way.

Best regards,
Steffen
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.