C++ÓëCµÄÇø±ð
±±º£
1£© º¯ÊýÉùÃ÷
l CÈç¹û²»Ð´·µ»ØÖµ£¬Ä¬ÈÏÊÇint£¬¶øC++Öв»Äܲ»Ð´·µ»ØÖµ(¿ÉÓÃvoid±íʾÎÞ·µ»ØÖµ)¡£
ÈçFunc1();
l int Func1()ÔÚCÖбíʾ¿É´øÈÎÒâ²ÎÊýµÄº¯Êý£¬ÕâÊÇCµÄ©¶´£¬Ê¹µÃËü±Ü¿ªÁ˲ÎÊýÀàÐͼì²é£»¶øC++Öбíʾ²»´ø²ÎÊýµÄº¯Êý¡£
2£© Í·ÎļþµÄÇø±ð
l C++µÄÍ·ÎļþÈ¥µôÁËCÖеÄ.h£¬ÒÔcǰ׺¿ªÊ¼¡£±ÈÈ磬<stdio.h> <stdlib.h>±äΪ<cstdio> <cstdlib>
l C´ø.hµÄÊÇ·ÇÄ£°å»¯µÄÍ·Îļþ£¬¶øC++ÊÇÄ£°å»¯µÄÍ·Îļþ¡£
.hÎļþÊDz»º¬ÃüÃû¿Õ¼äµÄ£¬ËùÒÔÒÔÇ°µÄ<iostream.h>ÊDz»ÐèÒªusingµÄ¡£
µ±È»Ò²¿ÉÒÔÓÃÀϵÄCÍ·Îļþ£¬µ«ÊÇ£¬ÔÚͬһ¸ö³ÌÐòÀï²»ÄÜ»ì×ÅÓã¬ËäÈ»±àÒë¿ÉÒÔͨ¹ý£¬µ«ÊÇ¿ÉÄÜ»á³öÏÖÎÊÌâ¡£
3£© register±äÁ¿
ÔÚCÓïÑÔÖУ¬ÊDz»ÄܶÔregister±äÁ¿È¡µØÖ·µÄ£¬ÒòΪËüûÓÐÐéµØÖ·£¬ÔڼĴæÆ÷Àï¡£¶øC++ÖУ¬ËüÊÇ¿ÉÒÔÈ¡Ö·µÄ£¬Õâʱ£¬C++±àÒëÆ÷»áºöÂÔregister£¬²»»á°ÑËü·Åµ½¼Ä´æÆ÷Àï¡£
4£© const±äÁ¿
CÖУ¬constÊÇÖ»¶ÁµÄ±äÁ¿£¬²»Êdz£Á¿£»C++ÖÐËüÊdz£Á¿¡£Çø±ðÓÃÀý×ÓÃèÊöÈçÏ£º
const int MAX = 10;
char buffer[MAX]; //CÖÐËüÊDz»ºÏ·¨µÄ£¬¿ÉÒÔÓÃenum»òdefineÌæ´ú£»
//C++ÖÐËüÊǺϷ¨µÄ¡£
±¾ÖÊ£ºCÖÐconst±äÁ¿·ÖÅäÔÚÈ«¾Ö¾²Ì¬Çø£»C++ÖÐÔòÔÚ³£Á¿Çø£¬±àÒë¹ý³ÌÖÐÖµ¾Í¶¨ÁË¡£
5£© typedef
ÔÚCÖУ¬
struct A
{
};
A a; //ÕâÊÇ´íÎóµÄ£¬ÔÚC++ÖÐÊǺϷ¨µÄ¡£
struct A a; //ÕâÊÇÕýÈ·µÄ
ÓÃÁËtypedefºó£¬CÖÐA a;Ò²ÊǺϷ¨µÄÁË¡£
6£© struct/union/class
l ¶ÔÓÚstruct/unionÊý¾Ý³ÉÔ±Ó뺯Êý³ÉÔ±µÄ·ÃÎÊÐÔÀ´Ëµ£¬ÆäĬÈÏÊÇpublic£»
l classÔòÊÇprivate¡£
l unionÁªºÏÌå²»ÄÜ×÷Ϊ»ùÀà¼Ì³Ð¡£
union A
{
};
class B: public A //±àÒë³ö´í
{
};
l ÄäÃûunion
union
{
int a;
float b;
};
ÔÚ³ÌÐòÀï¿ÉÒÔÖ±½Ó·ÃÎÊ
Ïà¹ØÎĵµ£º
¹ØÓÚ#ºÍ##ÔÚCÓïÑԵĺêÖУ¬#µÄ¹¦ÄÜÊǽ«ÆäºóÃæµÄºê²ÎÊý½øÐÐ×Ö·û´®»¯²Ù×÷£¨Stringfication£©£¬¼òµ¥Ëµ¾ÍÊÇÔÚ¶ÔËüËùÒýÓõĺê±äÁ¿Í¨¹ýÌæ»»ºóÔÚÆä×óÓÒ¸÷¼ÓÉÏÒ»¸öË«ÒýºÅ¡£±ÈÈçÏÂÃæ´úÂëÖеĺ꣺
#define WARN_IF(EXP) \
do{ if (EXP) \
& ......
LinuxÏÂC++¿ª·¢¹¤¾ß½éÉÜ
¡¡¡¡¸ÅÊö
¡¡¡¡¾ÍC£«£«¿ª·¢¹¤¾ß¶øÑÔ£¬ÓëWindowsÏÂ΢Èí£¨VC£¬ VS2005µÈ£©Ò»Í³ÌìÏÂÏà±È£¬Linux/UnixÏÂC£«£«¿ª·¢£¬¿ÉνÎ廨°ËÃÅ£¬¸÷ʽ¸÷Ñù¡£Emacs, vi, eclipse, anjuta£¬kdevelopµÈ²ã³ö²»Çî¡£
¡¡¡¡WindowsÏ£¬¿ª·¢¹¤¾ß¶àÒÔ¼¯³É¿ª·¢»·¾³IDEµÄÐÎʽչÏÖ¸ø×îÖÕÓû§¡£ÀýÈ磬VS2005¼¯³ ......
ÎÒÓõÄLinuxϵͳÊÇUbuntu 10.04
Ê×ÏÈ, °²×°wxWidgets 2.8. Ä¿Ç°wxWidgetsÓÐÁ½¸öÎȶ¨°æ±¾, 2.6ºÍ2.8, ÎÒÃÇÑ¡×îеÄ. ´ò¿ª “Ubuntu
Èí¼þÖÐÐÄ”, ÔÚËÑË÷¿òÀïÊäÈë “wxWidgets”, °ÑÏÂÃ漸¸öÃû×ÖÒÔ”wxWidgets Cross-platform C++ GUI
toolkit”¿ªÍ·µÄÈ«²¿°²×°. ×°Íêºó, ´ò¿ªÒ»¸öÖÕ¶Ë, ÊäÈ ......
C/C++ Reference
http://www.cppreference.com/
C++ Library Reference
http://www.cplusplus.com/ref/
Standard C++ Library Class Reference at Rogue Wave
http://www.roguewave.com/support/docs/hppdocs/stdref/
Dink ......
1. ÔõÑù½¨Á¢ºÍÀí½â·Ç³£¸´ÔÓµÄÉùÃ÷£¿ÀýÈ綨ÒåÒ»¸ö°üº¬N ¸öÖ¸Ïò·µ»ØÖ¸Ïò×Ö·ûµÄÖ¸ÕëµÄº¯ÊýµÄÖ¸ÕëµÄÊý×飿
Õâ¸öÎÊÌâÖÁÉÙÓÐÒÔÏÂ3 ÖÖ´ð°¸:
1. char *(*(*a[N])())();
2. ÓÃtypedef Öð²½Íê³ÉÉùÃ÷:
typedef char *pc; /* ×Ö·ûÖ¸Õë*/
typedef pc fpc(); /* ·µ»Ø×Ö·ûÖ¸ÕëµÄº¯Êý*/
typedef fpc *pfpc; /* ÉÏÃ溯ÊýµÄÖ¸Õë*/ ......