Hi, list!

I'm having a bit of a issue with classes.

Say I have a class that has a member that's simply a integer used for counting something.

I'll have a few instances (ten or so) and they will all be counting their own little thing on their own. So far so good. Now something happens and I'd like to reset all the counters to zero after which they should be independant again.

How to go about this in a efficient way?

I tried writing a static function to do this but it seems I misunderstand static functions. I thought that if I'd call a static function as a member of the class (not of a particular instance) then this function would be executed for all instances. That turns out not to be true; it only gets executed a single time. To make it more confusing (to me) referencing non-static int member of the class inside of a static function makes ChucK die while complaining about a nullpointer exception. In fact it will also die if I call the same function as a member of a particular instance. When I reference the number as " this.my_number" instead of just as "my_number" ChucK is a bit nicer about it and informs that "this" isn't allowed in static functions and refuses to run at all (better then suddenly dieing with cryptic complaints!).

My attempt to figure out what's going on;
===========================

class Foo
{
int my_number;

fun static void bar()
    {
    <<<my_number>>>;
    }
   
}

Foo A;
Foo B;

1 => A.my_number;
2 => B.my_number;

<<<"so far">>>;

//here we die
Foo.bar();
======================

"A.bar();" as a last line would also make ChucK die, BTW.

Is this a bug (the nullpointer, I mean)? Am I completely misunderstanding static functions? Is the only way to go about this to make a array of type Foo and loop over it going "0 => ArrayOfFoos[n].my_number" or something to that effect?

Thanks,
Kas.