maxpacer has asked for the wisdom of the Perl Monks concerning the following question:

Hi,a question about the usage of Inline::CPP. Could anyone help me? Thanks.
why can not use the father class' function in perl codes? Look below, there are 3 files, min.pl, test.h, test.cpp.
Run and the system shows:
$ perl min.pl
myget() is ok
Can't locate object method "get" via package "main::son" at min.pl line 11.

So it can call class son's function myget() but cannot call its father's function get().
Why, and how to solve it?

***Here is the file min.pl***
use Inline CPP; use Inline CPP => Config => MYEXTLIB => 'my path/test.o'; my $tc=new son(); my $sc=$tc->myget(); # why can not use its father' function? $sc=$tc->get(); __END__ __CPP__ # include "test.h" # include <iostream> using namespace std; class son: public Test { public: son():Test(){} double myget(); }; double son::myget() { cout<<"myget() is ok\n"; return 2; }
***Here is the test.h file:***
# include <iostream> using namespace std; class Test { public: double get(); };
***Here is the test.cpp file:***
#include "test.h"<br> <code> double Test::get() { cout<<"Test::get() is ok\n"; return 5; }

2006-03-09 Retitled by planetscape, as per Monastery guidelines
Original title: 'Inline::CPP'

Replies are listed 'Best First'.
Re: Using functions from Inline::CPP in my program
by Anonymous Monk on Mar 10, 2006 at 17:08 UTC
    Because Inline::Cpp knows about myget() and compiles it into the library via a son.o file. If there were a test.o file in the library, then your program would work. But you never tell Inline::Cpp to compile test.cpp!
      Thank you very much.
      So how to tell Inline::CPP to compile test.cpp?
      I have tried lots of methods. But they didn't work.

      (Of course, to put the codes in pl file is ok. I just want to write them in different files)