Colorado State University

This file defines the header for each page. An optional "icon" image (I use the textbook):

Replace this with info about this class:

CS253: Problem Solving with C++

Spring 2013

Example Local Static

Links to the various pages for this class:

Wish I could do this: * Schedule

Local Static Variables

#include <iostream>

using namespace std;

unsigned long next_id() {
    unsigned long id=800000000UL;
    return ++id;
}

int main() {
    cout << next_id() << '\n';
    cout << next_id() << '\n';
    cout << next_id() << '\n';
}
  1. Run it
  2. Make id static outside of next_id()
  3. Make id static inside of next_id()
Page: Main.ExampleLocalStatic
Modified: September 10, 2010, at 02:39 PM
Wiki: pmwiki-2.2.35
CS Department
Apply to CSU | Contact CSU | Disclaimer | Equal Opportunity
Colorado State University, Fort Collins, CO 80523 USA
© 2012 Colorado State University