docs.roxen.comView this page in a printer friendly mode
DocsPike7.0TutorialObject-Oriented Programming
Copyright  2012, Roxen Internet Software
Suggestions, comments & compliments

Object Orientation in General
Object Orientation in Pike
Creating and Using Objects
How to Create a Class
Classes as Record Types
Programs are Classes and Vice Versa
Multiple Inheritance
Access control

Classes as Record Types

Sometimes you just need to group a few values together. This is called a "record" in Pascal, and a "struct" in C. You can use Pike's class mechanism for this too. Just create a class with the data you are interested in:

class customer
  int number;
  string name;
  array(string) phone_numbers;

Then use it:

array(customer) all_customers = ({ });
customer c = customer();
c->number = 18;
c->name = "Ellen Ripley";
c->phone_numbers = ({ "555-8767", "555-4001" });
all_customers += ({ c });