Hello Jeff,
Thank you for ur reply.
> >package Animal;
> >sub named {
> > my $class = shift;
> > my $name = shift;
> > bless \$name, $class;
> >}
> >sub eat{
> > my $class = shift;
> > $class = ref($class) || $class;
> > my $food = shift;
> > print "$class eats $food\n";
> >}
>
> >In this program i dont understand what is the function of bless??? and
>where
> >xyz is stored.
>
>The bless() function takes a reference and a class, and says that the
>reference "belongs" to that class. Specifically, this means that the
>reference can access the methods of that class.
>
> $foo = Animal->named("Jeff");
>
>Now $foo is a reference (in your case, a scalar reference). If I were to
>dereference it, I'd see the string "Jeff":
>
> print $$foo; # Jeff
>
>Since $foo is an Animal object, I can call any method in the Animal class
>with $foo.
should we have to use the bless fuction in the constructor alone???? we can
use the created object ($foo) to invoke the function. isnt it??? so whatz
the real advandage of using bless function??? and why we need to bless that
particular object to some specific classes...
I really dont understand the functionality and advantages of using bless.
Thank you
Regards
Babylakshmi
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]