首页 > 其他 > 详细

static变量,全局变量,局部变量

时间:2014-07-19 02:48:26      阅读:244      评论:0      收藏:0      [点我收藏+]
/*
  c++ static变量,全局变量,局部变量
*/

#include<iostream>

using namespace std;

static int x=1;
static int y=2;

struct A
{
	static int x;
	static int y;
};

int A::x=3;
int A::y= x;//3 为什么是3,原因在哪里
//int A::y= ::x; //1 为什么是1,原因在哪里

int main()
{
	cout<<A::y<<endl;//3 

	cout<<A::x<<x<<A::y<<y<<endl;//3 1 3 2

	return 0;
}

static变量,全局变量,局部变量

原文:http://blog.csdn.net/greenapple_shan/article/details/37936979

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!