Returning a static int as an int??

This is a discussion on Returning a static int as an int?? within the C++ Programming forums, part of the General Programming Boards category; Hi all does any one know if it's correct to use a Static int and then return it as an ...

  1. #1
    ema
    ema is offline
    Registered User
    Join Date
    Feb 2002
    Posts
    11

    Red face Returning a static int as an int??

    Hi all

    does any one know if it's correct to use a Static int and then return it as an int?

    for example
    int IncJobCount()
    {
    static int job_count=0;
    job_count=job_count++;
    return job_count;

    } thanx alot

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,845
    To start at 0, all you need is
    static int job_count=0;
    return job_count++;


    To start at 1
    static int job_count=0;
    return ++job_count;

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Code review
    By Elysia in forum C++ Programming
    Replies: 71
    Last Post: 05-13-2008, 10:42 PM
  2. About aes
    By gumit in forum C Programming
    Replies: 13
    Last Post: 10-24-2006, 04:42 PM
  3. Replies: 2
    Last Post: 03-24-2006, 08:36 PM
  4. Half-life SDK, where are the constants?
    By bennyandthejets in forum Game Programming
    Replies: 29
    Last Post: 08-25-2003, 12:58 PM
  5. How do you search & sort an array?
    By sketchit in forum C Programming
    Replies: 30
    Last Post: 11-03-2001, 05:26 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21