Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

C/C++ Ö¸Ïò×ÓÀà¶ÔÏóµÄ»ùÀàÖ¸Õë

ÓÐÈçϳÌÐò£º
//-----------------
class A
{
public:
A()
{
printf( "base A\r\n" );
}
virtual ~A()
{
printf( "base ~A\r\n" );
}
public:
virtual void VirtualFunc()
{
printf( "base VirtualFunc\r\n" );
};
void Func()
{
printf( "base Func\r\n" );
}
void F1()
{
printf( "base F1\r\n" );
}
protected:
private:
};
class B : public A
{
public:
B()
{
printf( "derive B\r\n" );
}
~B()
{
printf( "derive ~B\r\n" );
}
public:
virtual void VirtualFunc()
{
printf( "derive VirtualFunc\r\n" );
};
void Func()
{
printf( "derive Func\r\n" );
}
void G1()
{
printf( "derive G1\r\n" );
}
protected:
private:
};
ÔÚÕâÁ½¸öÀàÖУ¬×ÓÀàB ÖØдÁË »ùÀàµÄ Á½¸öº¯Êý£¬Ò»¸öÊÇÐ麯Êý£¬Ò»¸ö²»ÊÇÐ麯Êý¡£
1. Èç¹ûmainº¯ÊýÈçÏ£º
int main(int argc, int* argv[])
{
A* pA = new B;  //»ùÀàÖ¸ÕëÖ¸Ïò×ÓÀà¶ÔÏó
pA->VirtualFunc();
pA->Func();
//pA->G1(); //³ö´í£º'G1' : is not a member of 'A'
delete( pA );
system("pause");
return 0;
}
ÔËÐнá¹ûÈçÏ£º
base A
derive B
derive VirtualFunc
base Func
derive ~B
base ~A
Ò²¾ÍÊÇ˵£¬Èç¹û×ÓÀàÖØдÁË»ùÀàµÄÐ麯Êý£¬ÄÇô¸ÃÖ¸Õ루»ùÀàÖ¸Õ룬µ«Ö¸ÏòÅÉÉúÀà¶ÔÏ󣩽«µ÷ÓÃ×ÓÀàµÄº¯Êý£»
¼´Ê¹×ÓÀàÖØдÁË×ÓÀàµÄ·ÇÐ麯Êý£¬¸ÃÖ¸ÕëÒ²²»»áµ÷ÓÃ×ÓÀàµÄº¯Êý¡£
2.
Èç¹ûmain º¯ÊýÈçÏ£º
int main(int argc, int* argv[])
{
B *pB = new B; //×ÓÀàÖ¸ÕëÖ¸Ïò×ÓÀà¶ÔÏó
pB->VirtualFunc();
pB->Func();
//pB->F1(); //ÕýÈ·£¬Êä³ö£ºbase F1¡£Çë×¢Ò⣺BÀàÊǹ«Óм̳ÐAÀà¡£¾ßÌå²Î¼û£ºC++µÄÈýÖּ̳з½Ê½
delete( pB );
system("pause");
return 0;
}
ÔòÔËÐнá¹ûÈçÏ£º
base A
derive B
derive VirtualFunc
derive Func
derive ~B
base ~A
¼´Èç¹ûÓÃ×ÓÀàÖ¸ÕëÖ¸Ïò×ÓÀà¶ÔÏó£¬Ôò¶¼µ÷ÓÃ×ÓÀàµÄº¯Êý¡£


Ïà¹ØÎĵµ£º

CÅÌϸ÷¸öÎļþ¼Ð¼ò½é

©À—WINDOWS
©¦ ©À—system32£¨´æ·ÅWindowsµÄϵͳÎļþºÍÓ²¼þÇý¶¯³ÌÐò£©
©¦ ©¦ ©À—config£¨Óû§ÅäÖÃÐÅÏ¢ºÍÃÜÂëÐÅÏ¢£©
©¦ ©¦ ©¦ ©¸—systemprofile£¨ÏµÍ³ÅäÖÃÐÅÏ¢£¬ÓÃÓÚ»Ö¸´ÏµÍ³£©
©¦ ©¦ ©À—drivers£¨ÓÃÀ´´æ·ÅÓ²¼þÇý¶¯Îļþ£¬²»½¨Òéɾ³ý£©
©¦ ©¦ ©À—spool£¨ÓÃÀ´´æ·Åϵͳ´òÓ¡Îļþ¡£ ......

Cº¯Êý·µ»Ø½á¹¹ÌåÔÚ»ã±àϵÄʵÏÖ

 
±àÒëÆ÷£ºvc++6.0(ÒòΪ´ËÖÖʵÏÖÒÀÀµ±àÒëÆ÷´¦Àí)
´Ë´¦Ö»¼òÒªÐðÊöһϻúÖÆ¡£²¢¸½²¿·Ö¹Ø¼üÖ¸ÁîÐòÁС£
×¼±¸£º
1£¬¹ØÓÚEBP£º³Æ×öÕ»»ùÖ·Ö¸Õ롣ΪʲôÕâÑù˵ÄØ£¿ÎÒÃÇÏÈÀ´¿´¿´º¯Êýµ÷ÓõĹý³Ì£º
²ÎÊý´ÓÓÒµ½×óѹջ¡£
callÖ¸ÁîÖ´ÐУ¬¸ÃÖ¸Áµ¼ÖÂEIPѹջ¡£
ÿ¸öº¯ÊýÇ°Á½¾ä±Ø¶¨ÊÇ£ºpush ebp   mov ebp,esp¡£Ôòca ......

C/C++³ÌÐòÔ±Á½ÄêÀú³Ì (1)

  ²»Öª²»¾õÒѾ­¹¤×÷Á½ÄêÁË£¬´ÇÈ¥ÁËÔ­À´µÄ¹¤×÷£¬ÓÖÅÜ»ØÁËÎÒÉÏѧµÄµØ·½¡£½ñÌìÅÜÈ¥Ò»¼ÒÊÒÓѽéÉܵĹ«Ë¾ÃæÊÔ¡£ÎʵÃÎÊÌâͦ¼òµ¥£¬µ«ÎÒ´ðµÄÈ´Õæ²»ÔõôµØ°¡¡£»ØÀ´ÓÖÑо¿ÁËһϣ¬·¢ÏÖÕâЩÎÊÌâÎÒÓ¦¸Ã¶¼Àí½â°¡£¬Ôõôµ½±ðÈËÎÊÆðµÄʱºò¾ÍÈ«ÍüÁËÒ»°ãÄØ¡£ÏëÏëÁË·¢ÏÖ»¹ÊÇѧµÄ²»µ½Î»¡£²»½ûÓÖÏëÆðÁËÕâô¶àÄêÀ´£¬ÎÒ¶¼Ñ§µ½ÁËʲô¶«Î÷ÄØ¡£
& ......

¶¨ÒåC/C++È«¾Ö±äÁ¿/³£Á¿¼¸ÖÖ·½·¨µÄÇø±ð

ÔÚÌÖÂÛÈ«¾Ö±äÁ¿Ö®Ç°ÎÒÃÇÏÈÒªÃ÷°×¼¸¸ö»ù±¾µÄ¸ÅÄ
 
1. ±àÒëµ¥Ôª(Ä£¿é)£º
    ÔÚIDE¿ª·¢¹¤¾ß´óÐÐÆäµÀµÄ½ñÌ죬¶ÔÓÚ±àÒëµÄһЩ¸ÅÄîºÜ¶àÈËÒѾ­²»ÔÙÇå³þÁË£¬ºÜ¶à³ÌÐòÔ±×îŵľÍÊÇ´¦ÀíÁ¬½Ó´íÎó(LINK ERROR), ÒòΪËü²»Ïñ±àÒë´íÎóÄÇÑù¿ÉÒÔ¸ø³öÄã³ÌÐò´íÎóµÄ¾ßÌåλÖã¬Äã³£³£¶ÔÕâÖÖ´íÎó¸Ðµ½°ÃÄÕ£¬µ«ÊÇÈç¹ûÄã¾ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ