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;
}
Ïà¹ØÎĵµ£º
ΪÁËʵÏÖÁ½¸öÊý×Ö½øÐн»»»£¬ÎÒÃÇͨ³£¿ÉÒÔÀûÓÃλÔËËãÀ´ÊµÏÖ
C++³ÌÐò swap(int a ,int b){a^=b^=a^=b;}
JAVA³ÌÐò swap(int a, int b){ a^=b;b^=a;a^=b; }»òÕß{ b^=(a^=b) ; a^=b;}
Èç¹ûJAVAÓÃC++µÄʵÏÖ·½Ê½Ôò»áµÃµ½ bµÃµ½ÁËaµÄÖµ£¬µ«ÊÇaÏÖÔÚµÄֵȴ² ......
¼Ìǰƪ¡¶Import Module¡·£¨http://blog.csdn.net/xiadasong007/archive/2009/09/02/4512797.aspx£©£¬¼ÌÐø·ÖÎöǶÈ벿·Ö»ù´¡ÖªÊ¶¡£Õâ´Î²»¶à˵£¬ÓÐʲôÎÊÌâ¼ÇµÃ¶à²éÓ¢ÎÄ×ÊÁÏ£¬¹úÄÚµÄÕâ·½Ãæ֪ʶÉÙ
»¹ÊÇÀ´¿´´úÂ룬дÍêÎÒ¾Í˯¾õÁË~
#include "python/python.h"
#include <iostream>
using namespace std;
int ......
¹þ¹þ£¡ÓÐÐÒÔÚijÍøÕ¾·¢ÏÖÕâƪÎÄÕ£¬¶Á°Õ£¬¾õµÃÂùÓеÀÀí£¬·¢À´´ó¼ÒÒ»Æð¹²ÃãÖ®
×ÜÊDZ»Í¬Ñ§ÃÇÎʵ½£¬ÈçºÎѧϰCºÍC++²Å²»Ã£È»£¬²Å²»ÊÇÂÒѧ£¬ÏëÁËһϣ¬ÕâÀï¸ø³öÒ»¸ö×ܵĻظ´¡£
¡¡¡¡Ò»¼ÒÖ®ÑÔ£¬»¶ÓÅÄש¹þ¡£
¡¡¡¡1¡¢¿ÉÒÔ¿¼ÂÇÏÈѧϰC.
¡¡¡¡´ó¶àÊýʱºò£¬ÎÒÃÇѧϰÓïÑÔµÄÄ¿µÄ£¬²»ÊÇΪÁ˳ÉΪһ¸öÓïÑÔר¼Ò£¬¶øÊÇÏ£Íû ......
#include <stdio.h>
#include <string.h>
/*
* decode encd with URL, the result saved to decd.
* return point to be decoded string.
* auth: baisoo email:baisoo@msn.com
*/
char *decode( char *encd, char decd[] );
int main( int argc, char *argv[] )
{
if( argc < ......