From: jweirich@... Date: 2001-08-12T01:18:50+09:00 Subject: [ruby-talk:19538] Re: the way class variables work >>>>> "MikkelFJ" == MikkelFJ writes: >> Class variable mimic "static" variables in Java or C++. Class >> instance variables are instance variables in the class object. MikkelFJ> I was thinking about the C++ analogy as well. But it MikkelFJ> doesn't hold. If you derive a class in C++ , any static MikkelFJ> members would have to be re-implemented in the derived MikkelFJ> class. [...] MikkelFJ> The derived class will not share the static member. Actually, it does. You can hide it by declaring another variable in a more local scope, but the original is still there, and accessible (with the :: operator). MikkelFJ> In templates you don't have to explicitly declare the MikkelFJ> instance member implementation, but it still creates a MikkelFJ> new instance. Templates declare a family of classes that are not related through inheritance. The analogy doesn't carry over. Comparison to C++ is tricky, because the semantics of the two languages are subtly different, but I think the parallel holds. However, if it doesn't help with *your* understanding, then forget it. -- -- Jim Weirich jweirich@one.net http://w3.one.net/~jweirich --------------------------------------------------------------------- "Beware of bugs in the above code; I have only proved it correct, not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)