Results 1 to 4 of 4

Thread: Static Array in Abstract - Load Once?

Hybrid View

  1. #1

    Thread Starter
    PowerPoster Halsafar's Avatar
    Join Date
    Jun 2004
    Location
    Saskatoon, SK
    Posts
    2,339

    Static Array in Abstract - Load Once?

    Alright, I have an abstract class MoveableObject, within it contains a static array type D3DVECTOR and a static function to generate the lookup table for 3d movement.

    The array is static, so that means even if 1 million units where created using the class MoveableObject, there would still be only 1 instance of the static array?

    MoveableObject <-- Human
    MoveableObject <-- Tank

    Still only 1 instance of the static D3DVECTOR?


    Edit:

    What about a static class instance?
    I have a static struct, and a static array it must declared:
    MoveableObject::UV_TABLE MoveableObject::VectorCircle[360];
    Is this correct?
    Last edited by Halsafar; Nov 8th, 2004 at 11:10 PM.
    "From what was there, and was meant to be, but not of that was faded away." - - Steve Damm

    "The polar opposite of nothingness is existance. When existance calls apon nothingness it shall return to nothingness." - - Steve Damm

    "When you do things right, people won't be sure if you did anything at all." - - God from Futurama

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    The array is static, so that means even if 1 million units where created using the class MoveableObject, there would still be only 1 instance of the static array?
    That's correct.

    What about a static class instance?
    What's that? You mean a file-level object of a class declared with the static keyword?
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  3. #3

    Thread Starter
    PowerPoster Halsafar's Avatar
    Join Date
    Jun 2004
    Location
    Saskatoon, SK
    Posts
    2,339
    Yah, for example:

    #include <clsSfxEngine.hpp>

    class MoveableObject
    {
    protected:
    static SfxEngine SFX;
    };

    class Human : public MoveableObject
    {
    };

    //in a function
    Human Player;

    Player.SFX.Play();

    Now no matter how many millions of objects need to use that instance of the sfx engine, it will still be only one?
    "From what was there, and was meant to be, but not of that was faded away." - - Steve Damm

    "The polar opposite of nothingness is existance. When existance calls apon nothingness it shall return to nothingness." - - Steve Damm

    "When you do things right, people won't be sure if you did anything at all." - - God from Futurama

  4. #4
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Yes, there will be only one.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width