Example:
// ConsoleApplication1.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <iostream> using namespace std; void sub(); int _tmain(int argc, _TCHAR* argv[]) { cout << "First run - " << endl; sub(); cout << "Second run - " << endl; sub(); system("PAUSE"); return 0; } void sub(){ int i; static int statici; cout << "before assign in sub()" << endl; cout << "i = " << i << endl; cout << "statici = " << statici << endl; i = 1; statici = 2; cout << "after assign in sub()" << endl; cout << "i = " << i << endl; cout << "statici = " << statici << endl; cout << endl; }
No comments:
Post a Comment