|
One class cannot (and shouldn't be forced to) share the lexical field arrays/hashes with derived classes. You have to use the accessors.
The equivalent of 'protected' on C++ member variables is to use 'restricted' accessor methods:
package Top; {
use Object::InsideOut;
my @info :Field('Std' => 'info', 'Restricted' => 1);
my %init_args :InitArgs = (
'INFO' => {
'Field' => \@info,
},
);
}
package Top::Middle; {
use Object::InsideOut 'Top';
sub print_info {
my $self = shift;
print($self->get_info(), "n");
}
}
package main;
my $obj = Top::Middle->new('INFO' => 'Some info');
# print($obj->get_info, "\n"); # Can't call restricted accessor
$obj->print_info();
|