C/C++ÎÊ´ð(3)£º¹ØÓÚ¹¹ÔìºÍÎö¹¹º¯ÊýʹÓöà̬
ÎÊ£º
ÔÚ¹¹Ôì»òÎö¹¹ÆÚ¼äÄÜʹÓÃÐ麯ÊýÂð£¿
´ð£º
ÄÜ£¬µ«×îºÃ²»ÒªÕâô×ö¡£
Ç°Á½ÌìÔÚ¹«Ë¾ÓÎÏ·ÏîÄ¿¿ª·¢¹ý³ÌÖУ¬ÔÚÎö¹¹º¯ÊýÖв»Ð¡Ðĵ÷ÓÃÁËÐ麯Êý£¬¶øÇÒ»¹ÊǸö´¿Ð麯Êý¡£
ÒòΪһֱÊÇÔÚRleaseģʽϹ¤×÷µÄ£¬µ¼ÖÂϵͳֱ½ÓÖÕÖ¹¿Í»§¶Ë£¬ËäÈ»¿ØÖÆ̨ÓдòÓ¡Õâ¸ö´íÎ󣬵«ÖÕֹ̫¿ì£¬Ò²Ã»¿´µ½¡£Çл»ÔÚDebugϵ÷ÊÔ£¬Ôò»á±¨R6025 -pure virtual function call µÄÔËÐÐʱ´íÎó¡£
µ±È»£¬Èç¹ûÔÚÎö¹¹º¯ÊýÖÐÖ±½Óµ÷Óô¿Ð麯Êý£¬±àÒëÆ÷Ò²²»Éµ(VS2008)£¬Ëü²»»áÈñàÒëͨ¹ýµÄ£¬ÒòΪ´¿Ð麯ÊýûÓÐʵÏÖÌ壬ËùÒÔ»á³öÏÖunresolved external symbolÁ´½Ó´íÎó¡£µ«ÊÇͨ¹ýÆäËûº¯Êý¼ä½Óµ÷Ó㬱àÒëÆ÷¾Í²»»á·¢ÏÖ£¬¾Í»á³ö´í¡£
Ö±½Ó¿´ÏÂÃæÕâ¸öÀý×Ó°É
class TestEffect
{
public:
TestEffect(){}
~TestEffect(){ release(); }
void release(){ clear(); }
virtual void clear() = 0;
};
class SubTestEffect: public TestEffect
{
public:
SubTestEffect(){}
~SubTestEffect(){}
virtual void clear(){ printf( "SubTestEffect::clear() called\n" }
};
ÕâÑùnew³öÀ´Ò»¸öSubTestEffectµÄʵÀý£¬ÔÚdeleteʱ¾Í»á±ÀÀ£¡£
¾ÍÕâ¸öÀý×Ó£¬ËµÒ»Ï¹ØÓÚ¹¹ÔìºÍÎöÔ캯ÊýÖÐʹÓöà̬
Ò»¡¢¹¹ÔìÅÉÉúÀà¶ÔÏóʱ£¬Ê×Ïȵ÷ÓûùÀ๹Ô캯Êý£¬Ö´ÐлùÀà³õʼ»¯¡£¶ø¶ÔÏóµÄÅÉÉúÀಿ·ÖÊÇδ³õʼ»¯µÄ¡£Êµ¼ÊÉÏ´Ëʱ¶ÔÏó»¹²»ÊÇÒ»¸öÅÉÉúÀà¶ÔÏó¡£
¶þ¡¢Îö¹¹ÅÉÉúÀà¶ÔÏóʱ£¬Ê×ÏÈÎö¹¹ËüµÄÅÉÉúÀಿ·Ö£¬È»ºó°´ÕÕÓë¹¹Ôì˳ÐòµÄÄæÐòµ÷ÓÃËüµÄ»ùÀàÎö¹¹¡£
ÕâÁ½ÖÖÇé¿öÏ£¬¶ÔÏ󶼲»ÊÇÍêÕûµÄ¡£ÎªÁËÊÊÓ¦ÕâÖÖ²»ÍêÕû£¬±àÒëÆ÷½«¶ÔÏóµÄÀàÐÍÊÓΪÔÚ¹¹Ôì»òÎöÔìÆڼ䷢ÉúÁ˱仯¡£ÔÚ»ùÀ๹Ôì»òÎö¹¹º¯ÊýÖУ¬½«ÅÉÉúÀà¶ÔÏóµ±×÷»ùÀàÀàÐͶÔÏóÀ´¶Ô´ý¡£
¹¹Ôì»òÎö¹¹ÆÚ¼äµÄ¶ÔÏóÀàÐͶÔÐ麯ÊýµÄ°ó¶¨ÓÐÓ°Ïì¡£
ËùÒÔÈç¹ûÔÚ¹¹Ôì»òÎö¹¹º¯ÊýÖÐʹÓöà̬£¬ÔòÔËÐеÄÊÇΪ¹¹Ô캯Êý»òÎö¹¹º¯Êý×ÔÉíÀàÐͶ¨ÒåµÄ°æ±¾¡£ÎÞÂÛÊÇÓɹ¹Ô캯Êý£¨»òÎö¹¹º¯Êý£©Ö±½Óµ÷ÓÃÐ麯Êý£¬»òÕß´Ó¹¹Ô캯Êý£¨»òÎö¹¹º¯Êý£©Ëùµ÷Óõĺ¯Êý¼ä½Óµ÷ÓÃÐ麯Êý£¬¶¼Ó¦ÓÃÕâÖְ󶨡£
¡¶Effective C++¡·µÚÈý°æÖÐÌõ¿î09,Scott Meyers¾ÍÃ÷È·Ö¸³ö£º¾ö²»ÔÚ¹¹Ôì»òÎöÔì¹ý³ÌÖе÷ÓÃvirtualº¯Êý£¬½²µÄÏêϸÇÒȨÍþ¡£ÓÐÈË˵C++³ÌÐòÔ±·ÖΪÁ½À࣬¶Á¹ýEffective C++µÄºÍû¶Á¹ýµÄ£¬ºÜÒź¶£¬ÎÒÊǺóÕß¡£
¸æ½ë×Ô¼º²»ÒªÔÚ¹¹Ôì»òÎö¹¹¹ý³ÌÖе÷ÓÃÐ麯Êý¡£
×¢Ò⣺“²»Òª”ºÍ“²»ÄÜ”£¬ÔÊÐíµ÷Ó㬵«¿ÉÄÜ´ï²»µ½
Ïà¹ØÎĵµ£º
ÎÒÒ»Ö±Ïë×öÒ»¸öÈí¼þ³öÀ´£¬Ö»ÊǼòµ¥µÄ£¬±ÈÈç˵һ¸ö¼Ó¼õ³Ë³ýµÄEXE¡£¿ÉÊÇÎÒÖªµÀÎÒ´íÁË£¬ÎÒ×î½üÑ¡ÐÞÁËÒ»Ãŵç×Ó¹¤³ÌÉè¼ÆÓëÖÆ×÷ºó²ÅÁ˽â±à³ÌµÄÄ¿µÄºÍ¹¤¾ßµÄ¶àÑùÐÔ¡£²»Í¬µÄÈí¼þÌṩ²»Í¬µÄ±àÒë»·¾³£¬ÎÒ·¢ÏÖÄ£ÄâÈí¼þµÄÇ¿µÄ¡£ÎÒʱ³£ÏëÎÒÊDz»ÊÇ¿ÉÒÔͨ¹ýÎÒÏÂÔØ°²×°µÄÈí¼þÀ´Ñ§Ï°Ð©Ô´³ÌÐò¡£ÊǵÄÓÐһЩ£¬¿ÉÊÇÍêÈ«¿´²»¶®£¬³ýÁË ......
1. ÓÃÔ¤´¦ÀíÖ¸Áî#define ÉùÃ÷Ò»¸ö³£Êý£¬ÓÃÒÔ±íÃ÷1ÄêÖÐÓжàÉÙÃ루ºöÂÔÈòÄêÎÊÌ⣩
#define SECONDS_PER_YEAR (60 * 60 * 24 * 365)UL
ÎÒÔÚÕâÏë¿´µ½¼¸¼þÊÂÇ飺
1). #define Óï·¨µÄ»ù±¾ÖªÊ¶£¨ÀýÈ磺²»ÄÜÒԷֺŽáÊø£¬À¨ºÅµÄʹÓ㬵ȵȣ©
2). ¶®µÃÔ¤´¦ÀíÆ÷½«Î ......
//linuxϱàÒëg++ $(mysql_config --cflags) ***.cpp $(mysql_config --libs)
/*mysqlÊý¾Ý¿âÖбíµÄÄÚÈÝ
mysql> select * from maindb;
+------------------+---------+-------------+---------+----------+---------------------+---------------------+---------------------+------------------- ......
1.Ö¸ÕëºÍÒýÓÃÓÐʲô·Ö±ð£»Èç¹û´«ÒýÓñȴ«Ö¸Õ밲ȫ£¬ÎªÊ²Ã´£¿Èç¹ûÎÒʹÓó£Á¿Ö¸ÕëÄѵÀ²»ÐÐÂð£¿
(1) ÒýÓÃÔÚ´´½¨µÄͬʱ±ØÐë³õʼ»¯£¬¼´ÒýÓõ½Ò»¸öÓÐЧµÄ¶ÔÏ󣻶øÖ¸ÕëÔÚ¶¨ÒåµÄʱºò²»±Ø³õʼ»¯£¬¿ÉÒÔÔÚ¶¨ÒåºóÃæµÄÈκεط½ÖØи³Öµ£®
(2) ²»´æÔڣΣգ̣ÌÒýÓã¬ÒýÓÃ±Ø ......