Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

c/c++ ¾²Ì¬±äÁ¿ Ò»¸öʵÀý

#include <iostream>
#include <cstdlib>
using namespace std;
class Foo
{
public:
Foo(int ii):i(ii){}
int getInt(){return i;}
private:
int i;
};
class Bar
{
public:
static int FooVal(){c++; return f.getInt();}
int callsFooVal(){return c;}
private:
static int c;
static Foo f;
};
int Bar::c=0;
Foo Bar::f(9);
int main()
{
Bar b;
cout<<Bar::FooVal()<<endl;
cout<<b.callsFooVal()<<endl;
cout<<Bar::FooVal()<<endl;
cout<<b.callsFooVal()<<endl;
cout<<Bar::FooVal()<<endl;
cout<<b.callsFooVal()<<endl;
system("PAUSE");
return 0;
}


Ïà¹ØÎĵµ£º

¸ßÖÊÁ¿C++/C±à³ÌÖ¸ÄÏ ÄÚ´æ¹ÜÀí

µÚ7Õ ÄÚ´æ¹ÜÀí
»¶Ó­½øÈëÄÚ´æÕâƬÀ×Çø¡£Î°´óµÄBill Gates Ôø¾­Ê§ÑÔ£º
640K ought to be enough for everybody
— Bill Gates 1981
³ÌÐòÔ±ÃǾ­³£±àдÄÚ´æ¹ÜÀí³ÌÐò£¬ÍùÍùÌáÐĵõµ¨¡£Èç¹û²»Ïë´¥À×£¬Î¨Ò»µÄ½â¾ö°ì·¨¾ÍÊÇ·¢ÏÖËùÓÐDZ·üµÄµØÀײ¢ÇÒÅųýËüÃÇ£¬¶ãÊǶ㲻Á˵ġ£±¾ÕµÄÄÚÈݱÈÒ»°ã½Ì¿ÆÊéµÄÒªÉîÈëµÃ¶à£¬¶ÁÕßÐèϸР......

CÖеĿɱä²ÎÊýÑо¿

Ò»£® ºÎν¿É±ä²ÎÊý
int printf( const char* format, ...);
ÕâÊÇʹÓùýCÓïÑÔµÄÈËËùÔÙÊìϤ²»¹ýµÄprintfº¯ÊýÔ­ÐÍ£¬ËüµÄ²ÎÊýÖоÍÓй̶¨²ÎÊýformatºÍ¿É±ä²ÎÊý£¨Óᱡ­¡±±íʾ£©¡£
¶øÎÒÃÇÓÖ¿ÉÒÔÓø÷ÖÖ·½Ê½À´µ÷ÓÃprintf,Èç:
printf("%d",value);
printf("%s",str);
printf("the number is %d ,st ......

C/C++ÐÞ¸ÄÎı¾Îļþ

mmapÊÇlinuxϵÄCreateFileMapping£¬ÓÃÀ´Ó³É䲢ͬ²½Îļþ¡£
ÕâÑùµÄ»°£¬±ÈÈçÎÒ×Ô¶¨ÒåÒ»ÖÖÎļþ¸ñʽ£¬°ÑËüдÈëµ½ÎļþÖУ¬ÏÖÔÚÏëÐÞ¸ÄÆäÖеÄÖµ£¬¾Í¿ÉÒÔÓÃÕâ¸öº¯Êý£¬°ÑÎļþÓ³Éäµ½ÄÚ´æÖÐ
È»ºóÓòÙ×÷Êý×éµÄ·½Ê½£¬À´½øÐÐÎļþµÄͬ²½¡£Èç¹û²»ÓÃÕâ¸öº¯Êý¾ÍµÃ£º
1¡¢¶¨ÒåÒ»¸ö½á¹¹Ìå
2¡¢¶¨Òå½á¹¹ÌåÊý×é
3¡¢¶ÁÈ¡Îļþ£¨w+£©
4¡¢ÐÞ¸ÄÎļþ ......

C/C++:³ÌÐòµÄÄÚ´æ·ÖÅ䷽ʽ Alvin

1.ÄÚ´æ·ÖÅ䷽ʽ
¡¡¡¡ÄÚ´æ·ÖÅ䷽ʽÓÐÈýÖÖ£º
¡¡¡¡[1]´Ó¾²Ì¬´æ´¢ÇøÓò·ÖÅä¡£ÄÚ´æÔÚ³ÌÐò±àÒëµÄʱºò¾ÍÒѾ­·ÖÅäºÃ£¬Õâ¿éÄÚ´æÔÚ³ÌÐòµÄÕû¸öÔËÐÐÆڼ䶼´æÔÚ¡£ÀýÈçÈ«¾Ö±äÁ¿£¬static±äÁ¿¡£
¡¡¡¡[2]ÔÚÕ»ÉÏ´´½¨¡£ÔÚÖ´Ðк¯Êýʱ£¬º¯ÊýÄÚ¾Ö²¿±äÁ¿µÄ´æ´¢µ¥Ôª¶¼¿ÉÒÔÔÚÕ»ÉÏ´´½¨£¬º¯ÊýÖ´ÐнáÊøʱÕâЩ´æ´¢µ¥Ôª×Ô¶¯±»ÊÍ·Å¡£Õ»ÄÚ´æ·ÖÅäÔËËãÄÚÖÃÓÚ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ