[C/C++ Digestion] – ÖØÔزÙ×÷·û
[C/C++ Digestion] –
ÖØÔزÙ×÷·û
×÷Õߣº
Jason Lee @
http://blog.csdn.net/jasonblog
ÈÕÆÚ£º
2010-04-17
[1]
ÖØÔزÙ×÷·û
ÖØÔزÙ×÷·û´Ó´óµÄ·½ÃæÀ´½²¿ÉÒÔ·ÖΪÁ½Àࣺ×îºÃ»ò±ØÐë×÷ΪÀàµÄ³ÉÔ±º¯ÊýµÄ£¬ÒÔ¼°Ïà·´¡£¶ø¾ßÌåµØ½²£¬×îºÃ»ò±ØÐë×÷ΪÀàµÄ³ÉÔ±º¯ÊýµÄÓи³Öµ²Ù×÷·û
( = )
¡¢Ï±ê²Ù×÷·û
( [] )
¡¢µ÷ÓòÙ×÷·û
( () )
¡¢³ÉÔ±·ÃÎʼýÍ·²Ù×÷·û
( ->
£¬Ä¿Ç°ÁгöµÄ²Ù×÷·û¶¼±ØÐëΪ³ÉÔ±º¯Êý
)
¡¢ÐǺŽâÒýÓòÙ×÷·û
( * )
¡¢¸´ºÏ¸³Öµ²Ù×÷·û
( +=
µÈ
)
¡¢×ÔÔö¡¢×Ô¼õ¡£ÆäËüµÄһЩ²Ù×÷·û£¬ÈçËãÊõ²Ù×÷·û¡¢ÏàµÈ²Ù×÷·û¡¢¹Øϵ²Ù×÷·ûºÍλ²Ù×÷·û£¬×îºÃ¶¨ÒåΪ·Ç³ÉÔ±º¯Êý£¬ÔÚÕâÖÖÇé¿öÏ£¬Í¨³£ÐèÒª½«Æ䶨ÒåΪÀàµÄÓÑÔªº¯Êý¡£µ±È»£¬»¹ÓÐһЩÊDz»½¨ÒéÖØÔصIJÙ×÷·û£¬È綺ºÅ¡¢È¡µØÖ·ÔËËã·ûºÍÂß¼ÔËËã·ûµÈ¡£
[2]
¸³Öµ²Ù×÷·û
¸³Öµ²Ù×÷·û±ØÐëÊÇÀàµÄ³ÉÔ±º¯Êý£¬ÒòΪ±àÒëÆ÷ÐèÒªÖªµÀÀàÊÇ·ñÓи³Öµ²Ù×÷·ûÕâ¸öÐÅÏ¢¡£²¢ÇÒ£¬¸³Öµ²Ù×÷·û±ØÐë·µ»Ø¶Ô
*this
µÄÒýÓã¬Ò²¾ÍÊÇ×ó²Ù×÷Êý
(
¶ÔÏó×ÔÉí
)
µÄÒýÓá£
ͬÑùµÄ£¬¸´ºÏ¸³Öµ²Ù×÷·ûÒ²Ó¦·µ»Ø¶Ô
*this
µÄÒýÓá£
ÈçÏÂÊÇÒ»¶ÎʾÀý´úÂ룺
#include <iostream>
using namespace std;
class Demo {
public:
Demo():val(0){}
Demo(int t): val(t){}
Demo(const Demo &demo){ val = demo.val; }
~Demo(){}
Demo& operator=(const Demo &demo){
val = demo.val;
return *this;
}
Demo& operator+=(const Demo &demo){
val += demo.val;
return *this;
}
void showVal(){ cout << val << endl; }
private:
int val;
};
int main(){
Demo d1 = 2;// Ê×Ïȵ÷ÓýÓÊÜÕûÐͲÎÊýµÄ¹¹Ô캯Êý´´½¨Ò»¸öÁÙʱ¶ÔÏó£¬ÔÙµ÷Óø´Öƹ¹Ô캯Êý
d1.showVal();
Demo d2;
d2 += d1;// ʹÓø´ºÏ¸³Öµ²Ù×÷·û
d2.showVal();
return 0;
}
ͨ³£¶¨ÒåÁ˸³Öµ²Ù×÷·û£¬ÄÇô½Ó×Ŷ¨Ò帴Öƹ¹Ô캯ÊýºÍ¸´ºÏ¸³Öµ²Ù×÷·ûÊDZȽϺÏÀíµÄ¡£½Ó×ÅÓÖΪÁËÌåÏÖ¸´Öƹ¹Ô캯ÊýµÄÔËÓã¬Ö±½ÓÔÚʵÀý»¯
d1
µÄʱºòʹÓÃÁË
Demo d1
= 2;
ÕâÑùµÄÓï¾ä£¬¾ÍÀàËÆ
string
str = “hello”;
Ïȵ÷ÓöÔÓ¦²ÎÊýµÄ¹¹Ô캯Êý´´½¨ÁÙʱ¶ÔÏóÔÙµ÷Óø´Öƹ¹Ô캯Êý¡£
[3]
ϱê²Ù×÷·û
Ïà¹ØÎĵµ£º
Ò»¡¢ÌáÇ°µÄ»°
¡¡¡¡ÒªËµCÓïÑÔºÍLinuxµÄ¹Øϵ´ó¼ÒÓ¦¸Ã¶¼²»»áÄ°Éú£¬LinuxϵͳÄں˾ÍÊÇÓÃCÓïÑÔ¿ª·¢µÄ£¬ËùÒÔËùÓеÄLinuxϵͳÏÂÃæ ¶¼»áÓÐCµÄ±àÒëµ÷ÊÔ¹¤¾ß£¬²»¹ýÕâЩ¹¤¾ß¶¼ÊÇÃüÁîʽµÄ£¬Õýʽ¿ª·¢µÄ»°»áºÜ²»·½±ã¡£FedoraÔÚ°²×°µÄʱºò¿ÉÒÔÑ¡Ôñ°²×°Fedora Eclipse£¬Õâ¸öIDEºÜÇ¿´ó£¬C£¬C++£¬Java£¬PythonµÈµÈ¶¼Ö§³Ö£¬¶øÇÒ±àÒ룬µ÷ÊÔºÍ ......
תÔØÇë×¢Ã÷³ö´¦£º±à³Ì±Ê¼ÇBLOG
¹¤ÓûÉÆÆäÊ£¬±ØÏÈÀûÆäÆ÷¡£ÓÃÁËÕâô¾ÃµÄlinux£¬ÏÖÔڱȽÏÖ÷Á÷µÄ¼¸¸öC/C++µÄIDE»ù±¾ÒѶ¼ÓùýÁË£¬ÏÖÔÚÀ´¶ÔËûÃÇ×öһϼòµ¥µÄ±È½Ï¡£
1¡¢VIM
Ê×ÏÈҪ˵µÄÊÇVIM¡£ÎÒÈÏΪ£¬VIMÖ»ÊÇÒ»¸ö±à¼Æ÷£¬²»ÄÜËãÊÇIDE¡£Ëä˵VIMÓкܶà²å¼þ£¬ÀýÈç´úÂëÕÛµþ¡¢µÝ½øµÈ£¬¿ÉÒÔ½«VIM×齨³É¼¸ºõÀàËÆÒ»¸öIDE£¬µ«Ê¼ÖÕËü²»ÊÇ× ......
ÈÕÖ¾
·ÖÏí¸øºÃÓѸ´ÖÆÍøÖ·Òþ²ØÇ©Ãûµµ´ó×ÖÌå
ÉÏһƪ ÏÂһƪ ·µ»ØÈÕÖ¾Áбí
ÔÚ2000ºÍxpÏÂÈçºÎ½«cÅÌfat32ת»»³Éntfs
±à¼ | ɾ³ý | ȨÏÞÉèÖà | ¸ü¶à▼
¸ü¶à¡ø
ÉèÖÃÖö¥
ÍƼöÈÕÖ¾
תΪ˽ÃÜÈÕÖ¾
Bandit ·¢±íÓÚ2007Äê12ÔÂ12ÈÕ 09:12 ÔĶÁ(9) ÆÀÂÛ(0) ·ÖÀࣺ ¸öÈËÈÕ¼Ç È¨ÏÞ: ¹«¿ª
1¡¢µ½ÃüÁîÌá ......
ÔÚnetbeansÖбà¼C/C++ÊÇÒ»ÖÖ²»´íµÄÑ¡Ôñ£¬ÏÂÃæÎÒ¾Í˵һÏÂÕû¸öÁ÷³ÌµÄÅäÖÃ
1.ÏÈÏÂÔØMinGW
ÕâÊDZàÒëc/c++µÄ±àÒëÆ÷£¬ÔÚwindowsÏÂÖ±½ÓÒÔ.exeµÄ·½Ê½ÔËÐУ¬ÏÂÒ»²½µÄ²Ù×÷£¬Ò»Ö±µ½°²×°Íê³É¡£
2.ÏÂÔØmsys
ÕâÊǺÍMinGWͬ²½Ê¹ÓÃ
3.ÅäÖû·¾³
ÔÚÎҵĵçÄÔ->ÊôÐÔ->¸ß¼¶->»·¾³±äÁ¿ÖÐÉèÖÃMinGWºÍmsysĿ¼ÖÐbinËùÔڵķ¾¶
4.²âÊÔ
ÓÃÃüÁîÐз½Ê½Ê ......
#include
void printptr(int *i){
printf("&i of printfptr = %#X\n",&i);
printf("i of printfptr = %#X\n",i);
printf("*i of printfptr = %d\n",*i);
printf("i+1 of printfptr = %#X\n",i+1);
printf("*(i + 1) of printfptr = %d\n",*(i ......