Here's what I remember from my Programming Languages class, although generalized because specifics are foggy and probably also language dependent. We studied Java when we did this: who knows how it applies to Perl (well, I bet someone here does, but whatever).
// Some Pseudo Code of Class Foo Class Foo { Static int FooCount; float FooVariable; Static int FooInc() {return FooCount++;} float GetFooVar() {return this.FooVariable;} } Foo MyFoo = New Foo(3.14); Foo MyFoo2 = New Foo(6.02);

We have Class Foo that has some static and normal variables. It also has static and normal methods. We instantiate this class in MyFoo with a New method and FooVariable = 3.14 and MyFoo2 with FooVariable = 6.02.

The New method also increments a Static Variable FooCounter which keeps track of how many Foo's we have running around in memory space. It does this with the Static Method FooInc(). Finally, there is a method GetFooVar() which returns the FooVariable of a specific Foo.

Now we have a memory block that contains the Foo Class along with its Static Variable FooCount = 2 and pointers to the Static Method FooInc() and normal Method GetFooVar().

There are also two memory blocks that contain the data of the Foo (one for MyFoo and another for MyFoo2). These two memory blocks also contain pointers back to the Foo Class as well as a bit more information about the Foo class. Using the class pointer and some memory offset information, they can access the GetFooVar() method. They do not have memory offset info to the FooInc() method though, because that is static and can only be called on the Foo class itself. (Probably it would be Private of course and only callable by Foo itself, but it's still Static.)

This is how I remember it, but no warantee or anything. It gets far more complex pretty quickly when you start adding things like inheritance or whatever, but I think this answers your question. Basically, one instance of Static information and methods, but each instance of the class will contain some pointer information for the class and each method it might need to call, so there will be a little extra bloat, but it should be trivial (a few bytes) compared to the size of even a single method.

By all means, please correct any errors oh compiler writing types (I don't take that class till next year).

-Lexicon


In reply to Re: OO Baggage by Lexicon
in thread OO Baggage by jynx

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.