[C/C++ Digestion] – ×Ôµ×ÏòÉϵØ̽¾¿Ð麯Êý
[C/C++ Digestion] –
×Ôµ×ÏòÉϵØ̽¾¿Ð麯Êý
×÷Õߣº
Jason Lee @
http://blog.csdn.net/jasonblog
ÈÕÆÚ£º
2010-05-19
»·¾³£º
Visual C++ Express
2008
ÉùÃ÷£º±¾ÎÄ·¢±íÔÚ
csdn
²©¿Í£¬ÈçÓÐתÔØ£¬Çë×¢Ã÷³ö´¦
[1]C++
¶ÔÏóÄ£ÐÍ»ù´¡
Ò»¸öÀàÖпÉÒÔ°üº¬¾²Ì¬Êý¾Ý³ÉÔ±¡¢¾²Ì¬³ÉÔ±º¯Êý¡¢·Ç¾²Ì¬³ÉÔ±º¯ÊýºÍ·Ç¾²Ì¬Êý¾Ý³ÉÔ±ÒÔ¼°Ð麯Êý¡£ÆäÖУ¬Ç°ÈýÕߣ¨¾²Ì¬Êý¾Ý³ÉÔ±¡¢¾²Ì¬³ÉÔ±º¯Êý¡¢·Ç¾²Ì¬³ÉÔ±º¯Êý£©¶¼²¢Ã»Óб»·Åµ½¶ÔÏóµÄ²¼¾ÖÖУ¬¿ÉÒÔ´ÓÒÔÏÂÁ½¶Î´úÂëµÃµ½ÑéÖ¤£º
#include <iostream>
using namespace std;
class Base {
};
int main(){
Base a;
cout << sizeof (a) << endl;// Êä³ö1
return 0;
}
ÉÏÊöµÄ
Base
ÀàÊÇÒ»¸ö¿ÕÀ࣬ռ¾ÝÁËÒ»¸ö×Ö½ÚµÄÄÚ´æ¿Õ¼ä£¬ÕâÊÇΪÁ˱£Ö¤Ã¿¸öÀàʵÀý»¯ºó¶¼ÓµÓжÀÒ»ÎÞ¶þµÄÄÚ´æ¿Õ¼ä¡£½Ó×ÅÎÒÃÇÍù
Base
ÀàÖÐÌí¼Ó¾²Ì¬Êý¾Ý³ÉÔ±¡¢¾²Ì¬³ÉÔ±º¯ÊýºÍ·Ç¾²Ì¬³ÉÔ±º¯Êý£º
#include <iostream>
using namespace std;
class Base {
public :
Base(){}
~Base(){}
static int v1;
static void f1(){}
void f2(){}
};
int main(){
Base a;
cout << sizeof (a) << endl;// ÈÔÈ»Êä³ö1
return 0;
}
ÔÚ¾¹ýÄÚÈÝÌî³äºó£¬
Base
ÀàµÄʵÀý
a
ÈÔÈ»½öÕ¼¾Ý
1
¸ö×Ö½ÚµÄÄÚ´æ¿Õ¼ä£¬Óë¿ÕÀàÎÞÒ죬Õâ˵Ã÷Á˾²Ì¬Êý¾Ý³ÉÔ±¡¢¾²Ì¬³ÉÔ±º¯ÊýºÍ·Ç¾²Ì¬³ÉÔ±º¯Êý²¢Î´±»·ÅÔÚ¶ÔÏóµÄÄÚ´æ²¼¾Öµ±ÖÐ
¡£
½ÓÏÂÀ´ÍùÀàÖÐÌí¼Ó·Ç¾²Ì¬Êý¾Ý³ÉÔ±£º
#include <iostream>
using namespace std;
class Base {
public :
int a;
int b;
};
int main(){
Base a;
cout << sizeof (a) << endl;// Êä³ö8
cout << hex << &a << endl;// Êä³ö0012F 3CC
cout << hex << &a.a << endl;// Êä³ö0012F 3CC
cout << hex << &a.b << endl;// Êä³ö0012F 3D0
return 0;
}
´ÓÉÏÃæµÄ´úÂë¿ÉÒÔ¿´³ö£ºÒ»£¬·Ç¾²Ì¬Êý¾Ý³ÉÔ±Êǻᱻ·Åµ½¶ÔÏóµÄÄÚ´æ²¼¾ÖÖУ»¶þ£¬Êý¾Ý³ÉÔ±ÊǸù¾ÝÉùÃ÷˳ÐòÓÐÐòµØÔÚÄÚ´æÖнøÐзֲ¼µÄ£»Èý£¬ÔÚûÓÐÐ麯ÊýµÄÇé¿ö϶ÔÏóËùÕ¼¾ÝµÄÄÚ´æ´óС¾ÍÊÇÊý¾Ý³ÉÔ±ËùÕ¼¾ÝµÄ¿Õ¼äÖ®ºÍ¡£²¼¾ÖÈçÏÂͼ£º
a
b
ÄÇôÈç¹ûÌí¼ÓÁËÐ麯ÊýÒÔºóÄØ£¿ÏÈ¿´Ò»¶Î´úÂ룺
#include <iostream>
usin
Ïà¹ØÎĵµ£º
ʹÓÃObjective-C½âÎöHTML»òÕßXML£¬ÏµÍ³×Ô´øÓÐÁ½ÖÖ·½Ê½Ò»¸öÊÇͨ¹ýlibxml£¬Ò»¸öÊÇͨ¹ýNSXMLParser¡£²»¹ýÕâÁ½ÖÖ·½Ê½¶¼ÐèÒª×Ô¼ºÐ´ºÜ¶à±àÂëÀ´´¦ÀíץȡÏÂÀ´µÄÄÚÈÝ£¬¶øÇÒ²»ÊǺÜÖ±¹Û¡£
ÓÐÒ»¸ö±È½ÏºÃµÄÀà¿âhpple£¬ËüÊÇÒ»¸öÇáÁ¿¼¶µÄ°ü×°¿ò¼Ü£¬¿ÉÒԺܺõĽâ¾öÕâ¸öÎÊÌâ¡£ËüÊÇÓÃXPathÀ´¶¨Î»ºÍ½âÎöHTML»òÕßXML¡£
°²×°²½Ö裺
-¼ÓÈë libx ......
Eclipse³ýÁË¿ÉÒÔ開發JavaÖ®Í⣬還Ö§Ô®ÁË許¶à語ÑÔ£¬現ÔÚÏȽé紹
C¡¢C++µÄ開發環¾³設¶¨£¬ÒÔááÓÐ機會ÔÙ½é紹ÆäËüµÄ¡£Enjoy it£¡
OS£ºWindows XP Professional SP1
ʹÓð汾£ºEclipse 2.1.2
Ò».Ê×ÏÈÒªÏÂ載CDT£¬Eclipse 2.1.2 ......
һƪ½²¶ÔÆë±È½ÏºÃµÄÎÄÕ£¬×ªÌùÈçÏÂ:
´óÖ±ê×¢Ò»¶þ:
1.ÄÚ´æ¶ÔÆë:¼ÆËã»úϵͳ¶Ô»ù±¾ÀàÐÍÊý¾ÝÔÚÄÚ´æÖдæ·ÅµÄλÖÃÓÐÏÞÖÆ£¬ËüÃÇ»áÒªÇóÕâЩÊý¾ÝµÄÊ×µØÖ·µÄÖµÊÇij¸öÊýk(ͨ³£ËüΪ4»ò8)µÄ±¶ÊýkÔò±»³ÆΪ¸ÃÊý¾ÝÀàÐ͵ĶÔÆëÄ£Êý(alignment modulus)
2.²»Í¬±àÒëÆ÷ĬÈϵÄ×î´ó¶ÔÆë×Ö½ÚÊýÊDz»Ò»ÑùµÄ,±ÈÈçvc==8,gcc==4,¿ÉÒÔͨ¹ ......
freadº¯ÊýºÍfwriteº¯Êý
1.º¯Êý¹¦ÄÜ
ÓÃÀ´¶Áдһ¸öÊý¾Ý¿é¡£
2.Ò»°ãµ÷ÓÃÐÎʽ
fread(buffer,size,count,fp);
fwrite(buffer,size,count,fp);
3.˵Ã÷
£¨1£©buffer£ºÊÇÒ»¸öÖ¸Õ룬¶ÔfreadÀ´Ëµ£¬ËüÊǶÁÈëÊý¾ÝµÄ´æ·ÅµØÖ·¡£¶ÔfwriteÀ´Ëµ£¬ÊÇÒªÊä³öÊý¾ÝµÄµØÖ·¡£
£¨2£©size£ºÒª¶ÁдµÄ×Ö½ÚÊý ......