c/c++ static
C++µÄstaticÓÐÁ½ÖÖÓ÷¨£ºÃæÏò¹ý³Ì³ÌÐòÉè¼ÆÖеÄstaticºÍÃæÏò¶ÔÏó³ÌÐòÉè¼ÆÖеÄstatic¡£Ç°ÕßÓ¦ÓÃÓÚÆÕͨ±äÁ¿ºÍº¯Êý£¬²»Éæ¼°ÀࣻºóÕßÖ÷Ҫ˵Ã÷staticÔÚÀàÖеÄ×÷Óá£
Ò»¡¢ÃæÏò¹ý³ÌÉè¼ÆÖеÄstatic
1¡¢¾²Ì¬È«¾Ö±äÁ¿
ÔÚÈ«¾Ö±äÁ¿Ç°£¬¼ÓÉϹؼü×Östatic£¬¸Ã±äÁ¿¾Í±»¶¨Òå³ÉΪһ¸ö¾²Ì¬È«¾Ö±äÁ¿¡£ÎÒÃÇÏȾÙÒ»¸ö¾²Ì¬È«¾Ö±äÁ¿µÄÀý×Ó£¬ÈçÏ£º
//Example 1
#include <iostream.h>
void fn();
static int n; //¶¨Ò徲̬ȫ¾Ö±äÁ¿
void main()
{
n=20;
cout<<n<<endl;
fn();
}
void fn()
{
n++;
cout<<n<<endl;
}
¾²Ì¬È«¾Ö±äÁ¿ÓÐÒÔÏÂÌص㣺
¸Ã±äÁ¿ÔÚÈ«¾ÖÊý¾ÝÇø·ÖÅäÄڴ棻
δ¾³õʼ»¯µÄ¾²Ì¬È«¾Ö±äÁ¿»á±»³ÌÐò×Ô¶¯³õʼ»¯Îª0£¨×Ô¶¯±äÁ¿µÄÖµÊÇËæ»úµÄ£¬³ý·ÇËü±»ÏÔʽ³õʼ»¯£©£»
¾²Ì¬È«¾Ö±äÁ¿ÔÚÉùÃ÷ËüµÄÕû¸öÎļþ¶¼ÊǿɼûµÄ£¬¶øÔÚÎļþÖ®ÍâÊDz»¿É¼ûµÄ£»¡¡
¾²Ì¬±äÁ¿¶¼ÔÚÈ«¾ÖÊý¾ÝÇø·ÖÅäÄڴ棬°üÀ¨ºóÃ潫ҪÌáµ½µÄ¾²Ì¬¾Ö²¿±äÁ¿¡£¶ÔÓÚÒ»¸öÍêÕûµÄ³ÌÐò£¬ÔÚÄÚ´æÖеķֲ¼Çé¿öÈçÏÂͼ£º
¡¡
´úÂëÇø
È«¾ÖÊý¾ÝÇø
¶ÑÇø
Õ»Çø
¡¡¡¡Ò»°ã³ÌÐòµÄÓÉnew²úÉúµÄ¶¯Ì¬Êý¾Ý´æ·ÅÔÚ¶ÑÇø£¬º¯ÊýÄÚ²¿µÄ×Ô¶¯±äÁ¿´æ·ÅÔÚÕ»Çø¡£×Ô¶¯±äÁ¿Ò»°ã»áËæן¯ÊýµÄÍ˳ö¶øÊͷſռ䣬¾²Ì¬Êý¾Ý£¨¼´Ê¹ÊǺ¯ÊýÄÚ²¿µÄ¾²Ì¬¾Ö²¿±äÁ¿£©Ò²´æ·ÅÔÚÈ«¾ÖÊý¾ÝÇø¡£È«¾ÖÊý¾ÝÇøµÄÊý¾Ý²¢²»»áÒòΪº¯ÊýµÄÍ˳ö¶øÊͷſռ䡣ϸÐĵĶÁÕß¿ÉÄܻᷢÏÖ£¬Example 1ÖеĴúÂëÖн«
static int n; //¶¨Ò徲̬ȫ¾Ö±äÁ¿
¸ÄΪ
int n; //¶¨ÒåÈ«¾Ö±äÁ¿
³ÌÐòÕÕÑùÕý³£ÔËÐС£
µÄÈ·£¬¶¨ÒåÈ«¾Ö±äÁ¿¾Í¿ÉÒÔʵÏÖ±äÁ¿ÔÚÎļþÖеĹ²Ïí£¬µ«¶¨Ò徲̬ȫ¾Ö±äÁ¿»¹ÓÐÒÔϺô¦£º
¾²Ì¬È«¾Ö±äÁ¿²»Äܱ»ÆäËüÎļþËùÓã»
ÆäËüÎļþÖпÉÒÔ¶¨ÒåÏàͬÃû×ֵıäÁ¿£¬²»»á·¢Éú³åÍ»£»
Äú¿ÉÒÔ½«ÉÏÊöʾÀý´úÂë¸ÄΪÈçÏ£º
//Example 2
//File1
#include <iostream.h>
void fn();
static int n; //¶¨Ò徲̬ȫ¾Ö±äÁ¿
void main()
{
n=20;
cout<<n<<endl;
fn();
}
//File2
#include <iostream.h>
extern int n;
void fn()
{
n++;
cout<<n<<endl;
}
±àÒë²¢ÔËÐÐExample 2£¬Äú¾Í»á·¢ÏÖÉÏÊö´úÂë¿ÉÒÔ·Ö±ðͨ¹ý±àÒ룬µ«ÔËÐÐʱ³öÏÖ´íÎó¡£ÊÔ׎«
static int n; //¶¨Ò徲̬ȫ¾Ö±äÁ¿
¸ÄΪ
int n; //¶¨ÒåÈ«¾Ö±äÁ¿
ÔٴαàÒëÔËÐгÌÐò£¬Ï¸ÐÄÌå»áÈ«¾Ö±äÁ¿ºÍ¾²Ì¬È«¾Ö±äÁ¿µÄÇø±ð¡£
2¡¢¾²Ì¬¾Ö²¿±äÁ¿
ÔÚ¾Ö²¿±äÁ¿Ç°£¬¼ÓÉϹؼü×Östatic£¬¸Ã±äÁ¿¾Í±»¶¨Òå³ÉΪһ¸ö¾²Ì¬¾Ö²¿±äÁ¿¡£
ÎÒÃ
Ïà¹ØÎĵµ£º
ϵͳ»·¾³£ºWindows 7
Èí¼þ»·¾³£ºVisual C++ 2008 SP1 +SQL Server 2005
±¾´ÎÄ¿µÄ£º±àдһ¸öº½¿Õ¹ÜÀíϵͳ
ÕâÊÇÊý¾Ý¿â¿Î³ÌÉè¼ÆµÄ³É¹û£¬ËäÈ»³É¼¨²»¼Ñ£¬µ«ÊÇ×÷ΪÎÒÓÃVC++ ÒÔÀ´±àдµÄ×î´ó³ÌÐò»¹ÊÇ´«µ½ÍøÉÏ£¬ÒÔ¹©²Î¿¼¡£ÓÃVC++ ×öÊý¾Ý¿âÉè¼Æ²¢²»ÈÝÒ×£¬µ«Ò²²»ÊDz»¿ÉÄÜ¡£ÒÔÏÂÊÇÎҵijÌÐò½çÃ棬ºóÃæ ......
Ê×ÏÈ¡¢ÎÒÃÇ¿´32λµÄÕûÊý£ºint ¡¢unsigned int¡¢long¡¢unsigned long ¡£ÕâЩ¶¼ÊÇ»ù±¾ÀàÐÍ£¬Ã»ÓÐunsigned¹Ø¼ü×ÖµÄÊÇÓзûºÅµÄ£¬·´Ö®ÊÇÎÞ·ûºÅµÄ¡£»¹ÓбÈÈçDWORD¡¢ UINTÕâЩҲֻÊÇд±ðÃû£¨typedef£©¶øÒÑ¡£ÓзûºÅÕûÊýÖµµÃ×¢ÒâµÄÊÇʲô·¶Î§ÄÚÊÇÕýÊý£¬Ê²Ã´·¶Î§ÊǸºÊý¡£ÕâÑù¶ÔÓÚ¼Ó¼õÔËËã¡¢±È½ÏÔËËãµÈÓкܴó°ïÖú£¬·ñÔòºÜÈÝÒ×Òç³ö»òÕß± ......
C/C++ÊÇ×îÖ÷ÒªµÄ±à³ÌÓïÑÔ¡£ÕâÀïÁгöÁË50ÃûÓÅÐãÍøÕ¾ºÍÍøÒ³Çåµ¥£¬ÕâЩÍøÕ¾Ìṩc/c++Ô´´úÂë¡£Õâ·ÝÇåµ¥ÌṩÁËÔ´´úÂëµÄÁ´½ÓÒÔ¼°ËüÃǵÄС˵Ã÷¡£ÎÒÒѾ¡Á¦°üÀ¨×î¼ÑµÄC/C++Ô´´úÂëµÄÍøÕ¾¡£Õâ²»ÊÇÒ»¸öÍêÕûµÄÇåµ¥£¬ÄúÓн¨Òé¿ÉÒÔÁªÏµÎÒ£¬ÎÒ½«»¶ÓÄúµÄ½¨Ò飬ÒÔ½øÒ»²½¼ÓÇ¿Õâ·½ÃæµÄÇåµ¥¡£
1¡¢http://snippets.dzone.com/tag/c/ --ÊýÒÔǧ¼Æ ......
µ½×îºó»¹ÊÇ×Ô¼º½â¾öÁË£¬µ¼Ö¸ÃÎÊÌâµÄÔÒòÊÇÔÚlinuxÆô¶¯µ½×îºó³öÏÖ£º
/bin/sh: can't access tty; job control turned off
¶ø³öÏָôíÎóµÄÔÒòºÍ½â¾ö·½·¨googleºóÓÐǧ°ÙÖÖ£¬³¢ÊÔÁ˺ܶàÖÖ¶¼Ã»ÓаïÎÒ½â¾öÎÊÌâ¡£
ÏÂÃæÊÇÎÒ×Ô¼ºµÄ½â¾ö·½·¨£º
1. vi /etc/inittab µÚÒ»ÐÐÌí¼Ó
console::sysinit:/etc/init.d ......
write by ¾ÅÌìÑãôá(JTianLing) -- blog.csdn.net/vagrxie
ÌÖÂÛÐÂÎÅ×é¼°Îļþ
Technorati ±êÇ©: JAVA
,C++
,Python
JAVA is not just another programming language. -- ÄäÃû
ѧϰ¸üеÄÓïÑÔ£¬ÓÐÖúÓÚÁ˽â±ðÈ˶ԾÉÓïÑÔÓÐÄÄЩ²»Âú¡£ -- ÄäÃû
Ç°ÑÔ
ÏÈ
˵Ã÷±¾ÎĵÄÐÐÎÄÏ°¹ß£¬ÎÄÕÂд×÷Á÷³ÌÒÔ±¾ÈËÔĶÁ¡¶Java Progra ......