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

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

µÚ7Õ ÄÚ´æ¹ÜÀí
»¶Ó­½øÈëÄÚ´æÕâƬÀ×Çø¡£Î°´óµÄBill Gates Ôø¾­Ê§ÑÔ£º
640K ought to be enough for everybody
— Bill Gates 1981
³ÌÐòÔ±ÃǾ­³£±àдÄÚ´æ¹ÜÀí³ÌÐò£¬ÍùÍùÌáÐĵõµ¨¡£Èç¹û²»Ïë´¥À×£¬Î¨Ò»µÄ½â¾ö°ì·¨¾ÍÊÇ·¢ÏÖËùÓÐDZ·üµÄµØÀײ¢ÇÒÅųýËüÃÇ£¬¶ãÊǶ㲻Á˵ġ£±¾ÕµÄÄÚÈݱÈÒ»°ã½Ì¿ÆÊéµÄÒªÉîÈëµÃ¶à£¬¶ÁÕßÐèϸÐÄÔĶÁ£¬×öµ½ÕæÕýµØͨÏþÄÚ´æ¹ÜÀí¡£
7.1ÄÚ´æ·ÖÅ䷽ʽ
ÄÚ´æ·ÖÅ䷽ʽÓÐÈýÖÖ£º
£¨1£© ´Ó¾²Ì¬´æ´¢ÇøÓò·ÖÅä¡£ÄÚ´æÔÚ³ÌÐò±àÒëµÄʱºò¾ÍÒѾ­·ÖÅäºÃ£¬Õâ¿éÄÚ´æÔÚ³ÌÐòµÄÕû¸öÔËÐÐÆڼ䶼´æÔÚ¡£ÀýÈçÈ«¾Ö±äÁ¿£¬static±äÁ¿¡£
£¨2£© ÔÚÕ»ÉÏ´´½¨¡£ÔÚÖ´Ðк¯Êýʱ£¬º¯ÊýÄÚ¾Ö²¿±äÁ¿µÄ´æ´¢µ¥Ôª¶¼¿ÉÒÔÔÚÕ»ÉÏ´´½¨£¬º¯ÊýÖ´ÐнáÊøʱÕâЩ´æ´¢µ¥Ôª×Ô¶¯±»ÊÍ·Å¡£Õ»ÄÚ´æ·ÖÅäÔËËãÄÚÖÃÓÚ´¦ÀíÆ÷µÄÖ¸ÁÖУ¬Ð§Âʺܸߣ¬µ«ÊÇ·ÖÅäµÄÄÚ´æÈÝÁ¿ÓÐÏÞ¡£
£¨3£© ´Ó¶ÑÉÏ·ÖÅ䣬Òà³Æ¶¯Ì¬ÄÚ´æ·ÖÅä¡£³ÌÐòÔÚÔËÐеÄʱºòÓÃmalloc»ònewÉêÇëÈÎÒâ¶àÉÙµÄÄڴ棬³ÌÐòÔ±×Ô¼º¸ºÔðÔÚºÎʱÓÃfree»òdeleteÊÍ·ÅÄÚ´æ¡£¶¯Ì¬ÄÚ´æµÄÉú´æÆÚÓÉÎÒÃǾö¶¨£¬Ê¹Ó÷dz£Áé»î£¬µ«ÎÊÌâÒ²×î¶à¡£
7.2³£¼ûµÄÄÚ´æ´íÎó¼°Æä¶Ô²ß
·¢ÉúÄÚ´æ´íÎóÊǼþ·Ç³£Âé·³µÄÊÂÇé¡£±àÒëÆ÷²»ÄÜ×Ô¶¯·¢ÏÖÕâЩ´íÎó£¬Í¨³£ÊÇÔÚ³ÌÐòÔËÐÐʱ²ÅÄܲ¶×½µ½¡£¶øÕâЩ´íÎó´ó¶àûÓÐÃ÷ÏÔµÄÖ¢×´£¬Ê±ÒþʱÏÖ£¬Ôö¼ÓÁ˸ĴíµÄÄѶȡ£ÓÐʱÓû§Å­Æø³å³åµØ°ÑÄãÕÒÀ´£¬³ÌÐòȴûÓз¢ÉúÈκÎÎÊÌ⣬ÄãÒ»×ߣ¬´íÎóÓÖ·¢×÷ÁË¡£
³£¼ûµÄÄÚ´æ´íÎó¼°Æä¶Ô²ßÈçÏ£º
u ÄÚ´æ·ÖÅäδ³É¹¦£¬È´Ê¹ÓÃÁËËü¡£
±à³ÌÐÂÊÖ³£·¸ÕâÖÖ´íÎó£¬ÒòΪËûÃÇûÓÐÒâʶµ½ÄÚ´æ·ÖÅä»á²»³É¹¦¡£³£Óýâ¾ö°ì·¨ÊÇ£¬ÔÚʹÓÃÄÚ´æ֮ǰ¼ì²éÖ¸ÕëÊÇ·ñΪNULL¡£Èç¹ûÖ¸ÕëpÊǺ¯ÊýµÄ²ÎÊý£¬ÄÇôÔÚº¯ÊýµÄÈë¿Ú´¦ÓÃassert(p!=NULL)½øÐмì²é¡£Èç¹ûÊÇÓÃmalloc»ònewÀ´ÉêÇëÄڴ棬Ӧ¸ÃÓÃif(p==NULL) »òif(p!=NULL)½øÐзÀ´í´¦Àí¡£
u ÄÚ´æ·ÖÅäËäÈ»³É¹¦£¬µ«ÊÇÉÐδ³õʼ»¯¾ÍÒýÓÃËü¡£
·¸ÕâÖÖ´íÎóÖ÷ÒªÓÐÁ½¸öÆðÒò£ºÒ»ÊÇûÓгõʼ»¯µÄ¹ÛÄ¶þÊÇÎóÒÔΪÄÚ´æµÄȱʡ³õֵȫΪÁ㣬µ¼ÖÂÒýÓóõÖµ´íÎó£¨ÀýÈçÊý×飩¡£
ÄÚ´æµÄȱʡ³õÖµ¾¿¾¹ÊÇʲô²¢Ã»ÓÐͳһµÄ±ê×¼£¬¾¡¹ÜÓÐЩʱºòΪÁãÖµ£¬ÎÒÃÇÄþ¿ÉÐÅÆäÎÞ²»¿ÉÐÅÆäÓС£ËùÒÔÎÞÂÛÓúÎÖÖ·½Ê½´´½¨Êý×飬¶¼±ðÍüÁ˸³³õÖµ£¬¼´±ãÊǸ³ÁãÖµÒ²²»¿ÉÊ¡ÂÔ£¬²»ÒªÏÓÂé·³¡£
u ÄÚ´æ·ÖÅä³É¹¦²¢ÇÒÒѾ­³õʼ»¯£¬µ«²Ù×÷Ô½¹ýÁËÄÚ´æµÄ±ß½ç¡£
ÀýÈçÔÚʹÓÃÊý×éʱ¾­³£·¢Éúϱꓶà1”»òÕß“ÉÙ1”µÄ²Ù×÷¡£ÌرðÊÇÔÚforÑ­»·Óï¾äÖУ¬Ñ­»·´ÎÊýºÜÈÝÒ׸ã´í£¬µ¼ÖÂÊý×é²Ù×÷Ô½½ç¡£
u Íü¼ÇÁËÊÍ·ÅÄڴ棬Ôì³ÉÄÚ´æй¶¡£
º¬ÓÐÕâÖÖ´


Ïà¹ØÎĵµ£º

C/C++ÖеÄ64λÕûÊý£¨__int64 and long long£©

¡¡¡¡ÔÚ×öACMÌâʱ£¬¾­³£¶¼»áÓöµ½Ò»Ð©±È½Ï´óµÄÕûÊý¡£¶ø³£ÓõÄÄÚÖÃÕûÊýÀàÐͳ£³£ÏÔµÃ̫СÁË£ºÆäÖÐlong ºÍ int
·¶Î§ÊÇ[-2^31,2^31)£¬¼´-2147483648~2147483647¡£¶øunsigned·¶Î§ÊÇ[0,2^32)£¬¼´
0~4294967295¡£Ò²¾ÍÊÇ˵£¬³£¹æµÄ32λÕûÊýÖ»Äܹ»´¦Àí40ÒÚÒÔϵÄÊý¡£
¡¡¡¡ÄÇÓöµ½±È40ÒÚÒª´óµÄÊýÔõô°ìÄØ£¿Õâʱ¾ÍÒªÓõ½C++µÄ64λÀ©Õ¹ ......

C/C++ std::string ÇдÊ

ÓÃÁËÈýÖÖ·½·¨...
#if 0
void StringTokenize(const std::string& strSrc, const std::string& strDelimit, std::vector<std::string>& vecSub)
{
if (strSrc.empty() || strDelimit.empty())
{
throw "tokenize: empty string\n";
......

memcachde Óë c/c++ Ó¦ÓÃ

ÐÞ¸Ämakefile£¬ÔÚLIBSÀïÃæ¼ÓÉÏ-lmemcached£¬±ÈÈçÔ­À´ gcc test.c£¬ÏÖÔÚ gcc test.c -lmemcached¡£Õâ¸ö¿â¾ÍÊÇlibmemcachedÌṩµÄ¡£
È»ºóÌí¼Ó#include<libmemcached/memcached.h>£¬Õâ¸öÎļþÒ²ÊÇlibmemcachedÌṩµÄ¡£
Ö÷º¯ÊýÀïÃæÐèÒªÌí¼Ó£º
    memcached_st *memc;
    uint32_t&nbs ......

³õʼ»¯º¯ÊýÖеÄÐ麯Êýµ÷Ó㨠C++ vs python £©

´úÂë+½á¹û£¬²»×ö½âÊÍ
µ±È»£¬¶ÔÓÚpythonûÓÐvirtual functionһ˵£¬¹À¼Æµ±×÷¶Ô±ÈÒ»¸öÀý×Ó¿´¿´°É¡£
#include <iostream>
using namespace std;
class base
{
public:
virtual void foo() { cout << "base" << endl; }
base() { foo() ;}
};
class derive: public base
{
pub ......

»ùÓÚCÓïÑÔºÍGELÓïÑÔµÄFlash±à³Ìз½·¨(תÌû)

ÒÔTMS320VC5402ΪÀý£¬Ì½ÌÖÒ»ÖÖ×ÛºÏÔËÓÃCÓïÑÔ¡¢Êý¾ÝÎļþ¼°GELÓïÑÔµÄFlash±à³Ìз½·¨¡£
¡¡¡¡¸Ã·½·¨ÍêÈ«²ÉÓÃCÓïÑÔ±àдÉÕд³ÌÐò£¬½â¾öÁËÖ¸Õë²»ÄÜ·ÃÎʸ߶ËFlashµÄÎÊÌâ;°ÑÒýµ¼±í×÷³ÉÊý¾ÝÎļþ£¬¿ÉʵÏÖ´óÒýµ¼±íµÄ·ÖÅú´Î¼ÓÔØ;ͨ¹ýGEL³ÌÐò¿ØÖÆC³ÌÐòÖ´ÐУ¬½ÏºÃµØÌåÏÖÁËFlash±à³ÌµÄÁ÷³Ì¡£
¡¡¡¡ÒýÑÔ
¡¡¡¡ÔÚDSPÓ¦ÓÃϵͳ¿ª·¢µÄºóÆÚ£¬Ò»° ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ