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'
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.