Static values, does the name matter?

Discussion in 'C++' started by Simon, Aug 10, 2005.

  1. Simon

    Simon Guest

    Hi,

    if I have something like

    void fooA()
    {
    static int ifoo = 0;
    }
    ...
    and
    ...
    void fooB()
    {
    static int ifoo = 0;

    ifoo++;
    }

    if I call fooB() does/(should?) the value of the first ifoo, (in fooA),
    change?

    Simon
    Simon, Aug 10, 2005
    #1
    1. Advertising

  2. Simon

    John Ratliff Guest

    Simon wrote:
    > Hi,
    >
    > if I have something like
    >
    > void fooA()
    > {
    > static int ifoo = 0;
    > }
    > ..
    > and
    > ..
    > void fooB()
    > {
    > static int ifoo = 0;
    >
    > ifoo++;
    > }
    >
    > if I call fooB() does/(should?) the value of the first ifoo, (in fooA),
    > change?
    >
    > Simon
    >
    >


    No. fooB()'s static ifoo is different than fooA()'s. Calling fooB will
    not affect anything local to fooA.

    --John Ratliff
    John Ratliff, Aug 10, 2005
    #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. Roy

    Does it really matter?

    Roy, Jul 12, 2005, in forum: ASP .Net
    Replies:
    8
    Views:
    442
    Robert Smith
    Jul 16, 2005
  2. John

    Does domain still matter?

    John, Jun 29, 2003, in forum: Java
    Replies:
    2
    Views:
    851
    Shripathi Kamath
    Jun 29, 2003
  3. SpaceCowboy
    Replies:
    6
    Views:
    523
    SpaceCowboy
    Aug 14, 2003
  4. Siah
    Replies:
    3
    Views:
    365
    Andy Dingley
    Mar 6, 2006
  5. Johan Tibell
    Replies:
    66
    Views:
    1,021
    Chris Torek
    Aug 7, 2006
Loading...

Share This Page