W0lf's Guide to Perl OOP for C/C++ Programmers

Wednesday, October 12, 2005

 

Creating Classes

Perl classes are perl packages. Say that twice, and two times more.

So if you want to create a class, just create a package. The class name should be the package name.

Now, all methods and variables you create belong to the namespace of the package you just created.

Ergo, you have a class.

Now, as C++ programmers, we're used to using two kinds of operators for traversing class/object spaces:

The scope-resolution operator: "::".

The class member operator : "."
and its sibling, the class pointer member access operator : "->".

Perl provides both these types of operators i.e. an operator to traverse the class namespace, and an operator to access object menbers.

The actual semantics of these operators are different, but hey, it sure looks like C++ to me.

Comments: Post a Comment



<< Home

Archives

October 2005  

This page is powered by Blogger. Isn't yours?