dz̸CÓëC++µÄÉè¼ÆÓë±à³Ì·ç¸ñ£¨¶þ£©
ÉÏ´Î×ܽáÁËC++£¨ÃæÏò¶ÔÏó£©Éè¼ÆµÄºËÐÄ˼Ï룬²¢ÇÒÀý¾ÙÁËʹÓÃÀàÄ£ÐÍÀ´Ìæ´úifºÍswitchµÄÒ»ÖÖ½ÏΪµäÐ͵ÄÇé¿ö¡£ÏÂÃæÏëÀ´Ì¸Ì¸C++ÔÚ±àÂë·½ÃæµÄÌص㡣
ÔںܶྵäµÄC++½Ì³ÌÖж¼ÓÐÒ»¸ö½¨Ò飺Ӧ¾¡Á¿Ê¹Óû§´úÂ루¿âµÄʹÓÃÕߣ©¿´ÆðÀ´¶ÌС¶ø¼òµ¥¡£°´ÕÕ³£Ê¶£¬¼òµ¥µÄ´úÂëͨ³£Òª±È´ó¶ÎµÄ´úÂëºÃÀí½â£¬¶øÓû§´úÂëͨ³£ÊµÏÖµÄÊÇ×îÉϲãµÄ¹¦ÄÜ»òÕß½çÃ棬ËüµÄ²»È·¶¨ÐÔ¸ü´ó£¬¾Ñé¸æËßÎÒÃÇ£¬×îÈÝÒ׳ö´íµÄ´úÂëÕýÊÇÄÇЩ±»Æµ·±Ð޸ĵĴúÂ룡Òò´Ë¼òµ¥µÄÓû§´úÂëÊÇÓкô¦µÄ£¬ÔÚ¿ª·¢Ò»¸ö¿âʱÎÒÃÇÓ¦¾¡Á¿×ñÊØÕâ¸ö½¨Òé¡£
C++ÓÐÁ½¸ö»úÖÆ¿ÉÒÔ°ïÖúÎÒÃÇʵÏÖÕâÒ»µã£¬Ò»¸öÊÇÔËËã·ûÖØÔØ£¬ÁíÒ»¸ö¾ÍÊÇÄ£°å¡£
C++µÄÔËËã·ûÖØÔØ»úÖƷdz£Ç¿´ó£¬ÕâÀï¾Í¾ÙÒ»¸ö¼òµ¥µÄÀý×Ó¡£CÓïÑÔÖÐÓÐÒ»ÖÖ¶ÔÊý×éµÄÌØÊâ³õʼ»¯·½Ê½£¬±ÈÈ磺int a[4] = {1,4,2,3}; ÕâÑùµÄÓï·¨·Ç³£ÇåÎúÇÒÈÝÒ×ÈÃÈËÀí½â£¬È»¶øºÜ¿ÉϧµÄÊÇ£¬ÕâÑùµÄÓï·¨²»ÄÜÓÃÓÚ¶ÔÊý×éµÄ¸³Öµ£¬¶ÔÊý×éµÄ¸³Öµ±ØÐëʹÓÃÒ»¸öÑ»·²Ù×÷£¬µ±Õâ¸öÊý×éÖеÄÄÚÈݲ»ÊÇ°´Ë³ÐòÅÅÁÐʱ£¬¶ÔÊý×éµÄ¸³ÖµºÜ¿ÉÄÜ»áÑݱä³ÉÒ»¸ö·Ç³£¸´ÔӵĹý³Ì¡£
µ«ÊÇÔÚC++ÖУ¬ÎÒÃÇÈ´¿ÉÒÔÀûÓÃÖØÔØÔËËã·ûÀ´ÊµÏÖÒ»ÖÖÏàËƵĸ³ÖµÓï·¨£¬·½·¨¾ÍÊÇÎÒÃÇÉè¼ÆÒ»¸öµü´úÆ÷£¬²¢ÖØÔظõü´úÆ÷µÄ , ÔËËã·û£¬È»ºóÔÙÉè¼ÆÒ»¸ö¿ÉÒÔʹÓÃÕâ¸öµü´úÆ÷µÄÊý×éÀ࣬²¢ÖØÔØÕâ¸öÊý×éµÄ=ÔËËã·û£¬ËüÃǵĴúÂë´óÖ»áÊÇÕâÑù£º
// Ò»¸öÖØÔØÁË,ÔËËã·ûµÄµü´úÆ÷Àà
class CCopyIterator
{
int * m_piItem;
public:
CCopyIterator(int in_aiItems[])
{
m_piItem = in_aiItems;
};
CCopyIterator & operator ,(int in_iVal)
{
*(m_piItem++) = in_iVal;
return *this;
}
};
//¿ÉÒÔʹÓÃCCopyIterator¸³ÖµµÄÊý×é
class CSmartArray
{
int m_aiItems[100]; // ÕâÀïʹÓÃÒ»¸ö¶¨³¤µÄÊý×éÊÇΪÁ˻رܻØÊÕÄÚ´æ¿Õ¼äµÄÎÊÌ⣬±Ï¾¹Õâ²»ÊÇÎÒÃÇÒªÌÖÂÛµÄÖ÷ÒªÎÊÌâ
public:
CCopyIterator operator =(int in_iFirstVal)
{
CopyIterator rtn(m_aiItems);
return (rtn, in_iFirstVal);
}
Ïà¹ØÎĵµ£º
ϵͳ»·¾³£ºWindows 7
Èí¼þ»·¾³£ºVisual C++ 2008 SP1 +SQL Server 2005
±¾´ÎÄ¿µÄ£º±àдһ¸öº½¿Õ¹ÜÀíϵͳ
ÕâÊÇÊý¾Ý¿â¿Î³ÌÉè¼ÆµÄ³É¹û£¬ËäÈ»³É¼¨²»¼Ñ£¬µ«ÊÇ×÷ΪÎÒÓÃVC++ ÒÔÀ´±àдµÄ×î´ó³ÌÐò»¹ÊÇ´«µ½ÍøÉÏ£¬ÒÔ¹©²Î¿¼¡£ÓÃVC++ ×öÊý¾Ý¿âÉè¼Æ²¢²»ÈÝÒ×£¬µ«Ò²²»ÊDz»¿ÉÄÜ¡£ÒÔÏÂÊÇÎҵijÌÐò½çÃ棬ºóÃæ ......
http://www.cppreference.com/wiki/cn/stl/algorithm/remove
Óï·¨:
#include <algorithm>
forward_iterator remove( forward_iterator start, forward_iterator end, const TYPE& val );
remove Ëã·¨ÒƳý [start,end) ·¶Î§Ö®ÄÚµÄËùÓÐÓë val ÏàµÈµÄÔªËØ¡£
´Ëº¯ÊýµÄ·µ»ØÖµÊÇÒ»¸öµ ......
¶¨ÒåÒ»¸ö×Ö·ûÖ¸Õ룬Æä±¾ÖʵĴ¦Àí·½Ê½ÊÇ°´×Ö·ûÊý×é´¦ÀíµÄ£¬ÔÚÄڴ濪±ÙÒ»¸ö×Ö·ûÊý×éÓÃÀ´´æ·Å×Ö·û´®³£Á¿£¬ÕâÑù±Ø¶¨»áÖÕÖ¹·û¡£¶øÕâÑùµÄÌØÐÔÒ²½ö¶ÔÓÚ×Ö·ûÖ¸Õë±äÁ¿¡£
ÔÚCÓïÑÔÖУ¬Í¨¹ýÊý×éÃû»òÕßÖ¸Õë±äÁ¿Êä³öÒ»¸ö×Ö·û´®£¬ÎÒÀí½âΪÁ½¸ö£º×Ö·û´®ÖÕÖ¹·ûµÄ´æÔÚ£»ÒÔ%s¸ñʽµÄÊä³ö·½Ê½¡£
char *p="I love china!";
& ......
CºêʵÀý
Õª×ÔLinuxÄÚºË2.6.21.5Ô´Âë(²¿·Ö)£¬Õ¹Ê¾ÁËÁ´±íµÄÁíÒ»ÖÖʵÏÖ˼·
δ²ÉÓÃANSI C±ê×¼£¬²ÉÓÃGNU C±ê×¼£¬×ñ´ÓGPL°æȨÐí¿É¡£
struct list_head {
struct list_head *next, *prev;
};
#define LIST_HEAD_INIT(name) { &(name), &(name) }
#define LIST_HEAD(name) \
struct list_ ......