Hi, Is there a way to make abstract base classes play well with
Inline::CPP ?
An xs wrapper is generated for every method in the base class, even
though the base class, being abstract, can never be instantiated
directly (only via a derived class which implements the virtual methods
not defined in the base). This causes compilation errors.
Here's an example:
#!/usr/bin/perl
use strict; use warnings; use v5.10;
package Some::Mumble::Pie;
use Inline CPP => config => namespace => 'Some';
use Inline CPP => <<'END_CPP' => CLEAN_AFTER_BUILD => 0;
#include <iostream>
using namespace std;
class Base {
public:
Base() { cout << "creating a Base()" << endl; }
virtual ~Base() { cout << "deleting a Base()" << endl; }
void run(int a) {
cout << "Base::run(" << a << ") called." << endl;
tick(a);
}
virtual void tick(int) = 0;
};
class Der : public Base {
public:
Der() { cout << "creating a Der()" << endl; }
virtual ~Der() { cout << "deleting a Der()" << endl; }
void tick(int a){ cout << "Der::tick(" << a <<") called." << endl; }
};
// int main() {
// Der *obj = new Der;
// obj->run(42);
// delete(obj);
// return 0;
// }
END_CPP
1;
my $obj = Some::Der->new();
$obj->run(42);