static C C++ÓïÒå
´æ´¢ÆÚstorage duration(extent)£¬ ָΪ¶ÔÏóÅäÖõÄÄÚ´æµÄ´æ»îÆÚ£¬±ÈÈçlocal extent
Éú´æ¿Õ¼äscope£¬Ö¸¶ÔÏóÔÚ³ÌÐòÄڵĴæ»îÇøÓò£¬¼´¿É±»·ÃÎʵķ¶Î§£¬±ÈÈçfile scope, static scope, local scope
C
local static object
º¯ÊýÄÚ²¿µÄobject£¬¾ßÓÐlocal scope£¬µ«ÊÇÿ´Îº¯Êý±»µ÷Óúó¸Ã¶ÔÏóµÄÄÚ´æ²»ÇåÀí£¬µ½Ï´ε÷Óû¹±£³ÖÔ×´
file static oject£¬static function
Ö»Óб»±àÒëÎļþµÄÉùÃ÷µãÖ®ºó²ÅÄÜʹÓøÃobjectºÍ¸Ãfunciton£¬´ïµ½Òþ²ØÍⲿ¶ÔÏóµÄÄ¿µÄ
C++
Ö±½Ó¶¨ÒåÔÚÎļþÖеıäÁ¿(ÎÞÂÛÊÇ·ñ¼Óstatic)£¬¾ßÓÐfile scope£¬¼´static scope£¬ÄÚ´æÒ»Ö±µ½³ÌÐò½áÊø²ÅÊÍ·Å
local static object
º¯ÊýÄÚ²¿µÄobject£¬¾ßÓÐlocal scope£¬µ«ÊÇÿ´Îº¯Êý±»µ÷Óúó¸Ã¶ÔÏóµÄÄÚ´æ²»ÇåÀí£¬µ½Ï´ε÷Óû¹±£³ÖÔ×´
static class member
classÄÚΨһµÄÒ»·Ý(¼´¸ú¶ÔÏóÎÞ¹Ø)£¬¿É¹²ÏíµÄ£¬member
const static class member
ͬstatic class member£¬µ«ÊÇ¿ÉÇÒ½ö¿ÉÔÚÉùÃ÷ʱ¸³Öµ
static class functions
²»´æÈ¡ÈκÎnon-static membersµÄº¯Êý
#pragma once
#include <string>
using namespace std;
class MyClass1
{
public:
MyClass1(void);
~MyClass1(void);
static void Test(void); //static class function
private:
static string _name; //static class member
static int _age; //static class member
int _testi;
const static int _size = 1; //const static class member
};
static int mytest2i = 0;
#include "StdAfx.h"
#include "MyClass1.h"
int MyClass1::_age;
string MyClass1::_name = "test"; //initialize here
MyClass1::MyClass1(void)
{
mytest2i = 0;
}
MyClass1::~MyClass1(void)
{
}
void MyClass1::Test(void)
{
MyClass1::_age = 1;
}
Ïà¹ØÎĵµ£º
VB
If MSComm1.PortOpen = True Then MSComm1.PortOpen = False
MSComm1.CommPort = i1
MSComm1.PortOpen = True
MSComm1.InputMode = comInputModeBinary
MSComm1.InBufferCount = 0
& ......
C++ÄÚ´æ·ÖÅäÃØ¼®—new£¬malloc£¬GlobalAllocÏê½â
......
C/C+ÓïÑÔstructÉî²ã̽Ë÷
×÷ÕߣºËᦻª ³ö´¦£ºPConline
1. structµÄ¾Þ´ó×÷ÓÃ
¡¡¡¡Ãæ¶ÔÒ»¸öÈ˵ĴóÐÍC/C++³ÌÐòʱ£¬Ö ......
Â¥Ö÷·¢±íÓÚ£º2009-07-24 10:11:03ÊÇÕâÑùµÄ,È¥Ò»¼Ò¹«Ë¾ÃæÊÔ,Óöµ½ÁËÒ»µÀcÓïÑÔµÄÌâ,¸öÈË
¸Ð¾õºÜ¹Ö,ÒÔǰû¼û¹ýÀàËÆµÄ,È»ºóÖ÷¿¼¹Ù˵ÕâÊǹØÓÚCÓïÑÔÇ¿ÈõÀàÐÍת»»Ê²Ã´µÄ,ÎҸоõËû
×Ô¼º¶¼²»ÍêÈ«Çå³þ,È»ºó»ØÀ´ÔÚÍøÉϲ鵽ÕâÊÇÓ¢¹ú½£ÇÅ´óÑ§ÍøÉϳöµÄ¼ÆËã»úÌâ :
#include <stdio.h>
#define init_employee(X,Y) {(X),(Y),wage ......
C ÖУ¬
int ºÍlongµÄ·¶Î§Ò»Ñù£¬Ö»Äܱíʾ(-2^31~2^31)ÕûÊý£¬¼´£¨-20ÒÚ¡« 20ÒÚ£©
unsigned int Óëunsigned long ·¶Î§ÊÇ(0 ~2^32),40ÒÚ¶àÒ»µã¡£
Èç¹ûÒª±íʾ¸ü´óһЩµÄÕûÊý£¬ÕâÁ½ÖÖÊý¾ÝÀàÐ;Ͳ»ºÃÓÃÁË£¬ÔÚACMÖо³£Òª´¦ÀíÕâÑùµÄÊý¾ÝÀàÐÍ£¬ÒÔǰÎҵı¿·½·¨ÊÇ×öÒ»¸öÕûÐÎÊý×飬ÿ¸öa[i]´æÒ»Î»£¬ÕâÑù¼Ó¼õ ......