in reply to OOP Beginner
You don't show us enough code to be sure what is going wrong, but the following sample may contain the kernel of an "ahh" moment for you:
use warnings; use strict; package BankAccount; sub new { my ($class, $name, $accountNo) = @_; return bless {name => $name, accountNo => $accountNo, balance => 0 +}, $class; } sub getName { my ($self) = @_; return $self->{name}; } package main; my $acct = BankAccount->new('Foo', '1234'); print $acct->getName();
Prints:
Foo
There is nothing much different there than you were doing aside from what I consider to be better style. I suspect that you weren't calling the member correctly, but as you don't show that code I can't be sure.
If the "Ahh" moment doesn't arrive for you show your equivalent of the code above.
|
|---|