Operator overloading/Inheritance from built-in types?

2006-10-05 Thread Wim Vanderbauwhede
Hi all, I want to create a kind of bitvector object. Ideally, I'd like to inherit from Array and then overload [],=, +,- etc. I tried to overload the '+' operator, but I can't get it to work as a method. Also, I'd like to overload the assignment operator. Is that at all possible? Below is my

Re: Operator overloading/Inheritance from built-in types?

2006-10-05 Thread David Brunton
Hopefully the following will help. If I've missed the thrust of your questions, feel free to disregard while someone else improves on my answer :) I only overloaded the infix:+ operator, but it should give you an idea. I would write the class comme ça: use v6-alpha; class Register { has

Re: Operator overloading/Inheritance from built-in types?

2006-10-05 Thread David Brunton
Haha, that will teach me for trying to golf on public mailing lists. It should actually read: sub int2vec ($n) { +(sprintf(%b,$n).split('')); # now I'm just golfing :-D } unless you only ever want to use it with the number 7. -db. - Original Message From: David