CS253

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

A link to enable editing of this page: Edit TopBar Replace this with info about this class:

CS253: Problem Solving with C++

Spring 2012

Example Local Static

Links to the various pages for this class:

Wish I could do this: * Schedule

Local Static Variables

(:source lang=cpp name=c.cc -inline:)

  1. 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';

} (:sourceend:)

  1. Run it
  2. Make id static outside of next_id()
  3. Make id static inside of next_id()

Modified: 2010-09-10T14:39

User: Guest

Check: HTML CSS
Edit History Source
Apply to CSU | Contact CSU | Disclaimer | Equal Opportunity
Colorado State University, Fort Collins, CO 80523 USA
© 2015 Colorado State University
CS Building