c/c++_static±äÁ¿µÄÓ¦ÓÃ
ÔÚCÓïÑÔ±à³ÌÖУ¬staticµÄÒ»¸ö×÷ÓÃÊÇÐÅÏ¢ÆÁ±Î£¡
±È·½Ëµ£¬Äã×Ô¼º¶¨ÒåÁËÒ»¸öÎļþ -- ¸ÃÎļþÖÐÓÐһϵÁеĺ¯ÊýÒÔ¼°±äÁ¿µÄÉùÃ÷ºÍ¶¨Ò壡
ÄãÏ£Íû¸ÃÎļþÖеÄһЩº¯ÊýºÍ±äÁ¿Ö»Äܱ»¸ÃÎļþÖеĺ¯ÊýʹÓã¬ÄÇô£¬Äã¿ÉÒÔÔڸú¯Êý¡¢±äÁ¿µÄÇ°Ãæ¼ÓÉÏstatic£¬´ú±íËûÃÇÖ»Äܱ»µ±Ç°ÎļþÖеĺ¯ÊýʹÓã¡
¶øÔÚC++ÖУ¬ÓÃstaticÀ´×÷ΪÐÅÏ¢ÆÁ±Î¾ÍÏÔµÃûÓбØÒªÁË£¡ÒòΪ£¬C++ÓÐÁËÐÅÏ¢ÆÁ±ÎµÄÀûÆ÷ -- class»úÖÆ£¡
ÀàÖеÄprivateÊôÐԵıäÁ¿ºÍº¯Êý¾Í¶ÔÍâ½ûÖ¹·ÃÎÊ£¡
È»ºóÊÇC/C++ͨÓõĺ¯Êý×÷ÓÃÓòµÄstaticÐ͵ıäÁ¿£¡ÆäÄ¿µÄ£¬Ò²ÊÇΪÁËÐÅÏ¢µÄÆÁ±Î£¡
int fun() {
static int a = 1;
a++;
}
ÔÚµÚÒ»´Î½øÈëÕâ¸öº¯ÊýµÄʱºò£¬±äÁ¿a±»³õʼ»¯Îª1£¡²¢½Ó×Å×ÔÔö1£¡
ÒÔºóÿ´Î½øÈë¸Ãº¯Êý£¬a¾Í²»»á±»Ôٴγõʼ»¯ÁË£¬½ö½øÐÐ×ÔÔö1µÄ²Ù×÷£¡
ÔÚstatic·¢Ã÷Ç°£¬Òª´ïµ½Í¬ÑùµÄ¹¦ÄÜ£¬ÔòÖ»ÄÜʹÓÃÈ«¾Ö±äÁ¿£º
int a = 1;
int fun() {
a++;
}
ÄÇô£¬aµÄÖµ¾ÍÓпÉÄܱ»ÆäËûº¯ÊýËù¸Ä±ä£¡
×îºó£¬ËµËµÀàÖеÄstatic±äÁ¿ºÍº¯Êý¡£
ÕâÖÖ´æ´¢ÊôÐԵıäÁ¿ºÍº¯ÊýÊÇͬһÖÖÀàµÄ²»Í¬ÊµÀýÖ®¼äͨÐŵÄÇÅÁº£¡
#include <iostream>
using namespace std;
class A {
public:
static int num; // ͳ¼Æ´´½¨Á˶àÉÙ¸öʵÀý
A () {num++}; // ÿ´´½¨Ò»¸öʵÀý£¬¾ÍÈÃnum×ÔÔö1
// ·µ»Øͨ¹ý¹¹Ô캯ÊýËù´´½¨¹ýµÄAÀàʵÀýµÄÊýÄ¿
static int how_many_instance() {
return num;
}
}
static A::num = 0; // ÐèÒªÔÚÀàÉêÃ÷µÄÍⲿµ¥¶À³õʼ»¯£¡
int main() {
cout << A::how_many_instance() << endl;
A a, b, c, d;
cout << A::how_many_instance() << endl;
Ïà¹ØÎĵµ£º
תÔØ×Ô£ºhttp://www.cnblogs.com/chio/archive/2007/11/26/972152.html
CRTÔÏÈÊÇÖ¸Microsoft¿ª·¢µÄC Runtime Library£¬ÓÃÓÚ²Ù×÷ϵͳµÄ¿ª·¢¼°ÔËÐС£ºóÀ´ÔÚ´Ë»ù´¡ÉÏ¿ª·¢ÁËC++ Runtime Library£¬ËùÒÔÏÖÔÚCRTÊÇÖ¸Microsoft¿ª·¢µÄC/C++ Runtime Library¡£ÔÚVCµÄCRT/SRCĿ¼Ï£¬¿ÉÒÔ¿´µ½CRTµÄÔ´Â룬²»½öÓÐCµÄ£¬Ò²ÓÐC++µ ......
Java "ÓÐÀíÓÉ" ±È C++ ¿ì
×î½üÉÏCSDN±È½Ï¶à£¬ÓÖ¿´µ½ËµJava±ÈC++¸ü¿ìµÄÌû×Ó¡£
JavaÔÚijЩÇé¿öϱÈC++¿ìÎÒÈÏΪÊǺÜÓеÀÀíµÄ¡£ÀýÈç¿ÉÒÔ¸ù¾ÝÌض¨µÄCPU½øÐÐÓÅ»¯µÈµÈ¡£
ÓÐλ½Ð wingfiring(±ð¶ºÁË)(·ÇµäÐÍͺ×Ó) µÄÀÏÐÖ·¢ÁËÒ»¸öÌû×Ó£¬ÔÎÄÈçÏ£º
ºÃ£¬ÎÒûÄÇô¶àʱ¼ä³³C++ºÃ»¹ÊÇJavaºÃ£¬ËùÒÔ£¬ÎÒ¾ÍÏÈÕ°ÑöÒ»ÏÂÂ¥Ö÷¸ø³öµÄÁ ......
--------Éý¼¶ Space C V2.1.2
2010.2.16
*½«Èí¼þ½çÃæ·ç¸ñÐÞ¸ÄΪ¸úËæWindowsϵͳ£¬ÃÀ»¯ÁËÈí¼þ½çÃ棬ʹ¿ª·¢¹ý³Ì¸üÊæÐÄ¡£
*½«DOXBoxÐéÄâµÄ¿ªÆô/¹Ø±Õ£¬¸ü¸Äµ½±àÒëÅäÖеÄTC2.0Ò³Ãæ¡£
*Ôö¼Ó‘СÓïÑÔ’Tiny µÄ±àÒëÆ÷-Smmy£¬²¢¸½´øDOS°æµÄTMMY_DOSÐéÄâ»ú¡£
*Ôö¼Ó‘СÓïÑÔ’Tiny µÄ¶ÔÓ¦Windows°æÐéÄâ»úTMMY ......
±¾Îļٶ¨ÄãÒѾÊìϤJava,EclipseµÄ°²×°,²¢ÄÜ˳ÀûÆô¶¯ºÍÔËÐÐEclipse.´ËÍâÒòΪ¸÷Èí¼þ°æ±¾ÔÚ²»¶Ï¸üУ¬ÓÐЩµØ·½¿ÉÄܲ»×¼È·£¬ÒÔ×îеġ¢ÔÎÄ×ÊÁÏΪ׼¡£
¾àÉÏÒ»´ÎдºÍµ÷C++³ÌÐò£¬ÒѾ5¡¢6ÄêÁË£¬¹âÒõÜóÜÛËêÔÂÎÞÇ飬ÏÖÔÚÔÙÖØÐÂÊ°ÆðÀ´£¬ºÜ¶à¶«Î÷¶¼Òª´ÓÍ·À´¡£WindowsÏÂC/C++µÄIDEÓкܶ࣬ÎÒÖªµÀµÄ¾ÍÓÐMS Visual Studio£¬Borla ......
Regarding C Run-Time Error R6034 for VS2005/VS2008
Regarding "C Run-Time Error R6034"
Microsoft's recommendation is very confusing. That is, it recommends to include a manifest file and to re-compile the project.
I recently had a problem with 'R6034' error message even with a manifest file ......