Thread Virtuelle Methoden in Perl? (5 answers)
Opened by Gast at 2006-11-20 16:44

frodus
 2006-11-20 17:02
#71875 #71875
User since
2003-09-26
147 Artikel
BenutzerIn
[default_avatar]
Versuch es mal so:

Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/perl

{
package a;

sub new {
my $invocation = shift();
my $class = ref($invocation) || $invocation;
my $self = {};
my $bless = bless($self, $class);
return $bless;
}

sub a1 {
my $self = shift();
print "hi I'm a\n!";
}

sub a2 {
my $self = shift();
$self->a1();
}
}
{
package b;

@ISA = qw(a);

sub a1 {
my $self = shift();
print "hi I'm b\n";
}

1;
}

my $a = new a();
my $b = new b();

$b->a2();
$a->a2();


Gruss,

Frodus

View full thread Virtuelle Methoden in Perl?