CS253

CS253: Software Development with C++

Spring 2009

Example Local Static

Local Static Variables

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

  1. include <iostream>

using namespace std;

unsigned long long next_id() {

        unsigned long long id=800000000ULL;
        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: 2009-02-05T22:34

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