C++: Static variable

A static variable takes its first initiated value and remains unchanged.

#include "stdafx.h"

#include <iostream>

using namespace std;

void main()
{
	for (int i = 2; i<5; ++i)
	{
		static int a = i;
		cout << a << endl;
	}

	system("pause");
}

static

Series Navigation<< C++: Friend Class