When do we want to declare static object

Discussion in 'C++' started by ron_werbin, Apr 1, 2006.

  1. ron_werbin

    ron_werbin Guest

    Hi there,

    In what cases will we want to declare our objects static?
    for example

    *.cpp:

    static String xStr;

    Than you for any help,

    Ron
     
    ron_werbin, Apr 1, 2006
    #1
    1. Advertising

  2. ron_werbin

    Moonlit Guest

    Hi,

    Wel I usually have a logging object around that I want to be able to access
    from any method or in any file. I usually have that object in the file with
    the main routine ( 'CLog Log( "Filename.log" );'. (and 'extern CLog Log;' in
    the header file).

    Another case would be a class variable. For instance to serialize classes to
    and from storage (be it memory disk or somehting else). I have a virtual
    function that returns the name of the class. On serializing I first write
    that class name (this makes sure a derived will be correctly deserialized).
    When deserializing an object located on the heap first the classname is read
    then the class is created by mapping the class name in a map<ClassName,
    CreateMethod>. The created object is then deserialized in the allocated
    space.


    --


    Regards, Ron AF Greve

    http://moonlit.xs4all.nl

    "ron_werbin" <> wrote in message
    news:...
    > Hi there,
    >
    > In what cases will we want to declare our objects static?
    > for example
    >
    > *.cpp:
    >
    > static String xStr;
    >
    > Than you for any help,
    >
    > Ron
    >
     
    Moonlit, Apr 1, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Old Wolf
    Replies:
    1
    Views:
    437
    Victor Bazarov
    May 10, 2005
  2. Javi
    Replies:
    2
    Views:
    1,107
  3. tropos
    Replies:
    3
    Views:
    478
  4. Replies:
    1
    Views:
    389
    Victor Bazarov
    Apr 6, 2006
  5. ZelluX
    Replies:
    24
    Views:
    929
    Hendrik Maryns
    Nov 19, 2007
Loading...

Share This Page