CÒÅÁôµÄ½á¹¹Ìøת
±±º£
1) goto
goto Ö»ÄÜÔÚÒ»¸öº¯ÊýÄÚÌøת¡£½¨ÒéÉÙÓã¬Ê¹µÃ³ÌÐòά»¤ÆðÀ´ÈÝÒ׳ö´í£»µ«ÊÇ£¬ÔÚÓжà¸öÑ»·Çé¿öÏÂÌøת£¬ÓÐʱÓÃgoto¿ÉÒÔʹµÃÎÊÌâ±äµÃ¼òµ¥¡£
class A
{
public:
A(){}
~A(){}
};
int main()
{
{
A a;
goto Label1;
}
Label1:
cout<<”end”<<endl;
return 0;
}
2) setjmp/longjmp
·Ç¾Ö²¿ÓòÌøת(nonlocal goto)£¬¿ÉÓÃÓÚÔÚ²»Í¬º¯ÊýÄÚÌøת£¬²½ÖèÈçÏ£º
l include <setjmp.h>
l jmp_buf JumpBuffer
//ÌøתµÄλÖýṹ
l setjmp(JumpBuffer)
±£´æµ±Ç°µÄλÖ㬽«À´Ìøתµ½ÕâÀï
l longjmp(JumpBuffer, ÕûÊý)
jmp_buffer jmpbuf;
void Func()
{
cout << “ get in “ <<endl;
A a;
longjmp(jmpbuf, 1);
cout << “ never get here “<<endl;
}
int main()
{
cout << “ get in main “ <<endl
if( setjmp (jmpbuf ) == 0 )
{
cout<<”set lable”<<endl;
Func();
}
else
{
cout<<” jmp to here”<<endl;
}
}
Ïà¹ØÎĵµ£º
ÍøÉÏÒ»µÀ½ðɽµÄÃæÊÔÌ⣺
http://topic.csdn.net/u/20100524/14/0eff992a-2849-4db6-bdaa-d4a200e79b7c.html
Çë·Ö±ðÓÃC++µÄÃæÏò¶ÔÏóºÍ·ºÐÍ»úÖÆ£¬±àдʵÏÖTemplate MethodģʽµÄʾÀý´úÂ룬²¢±È½ÏÁ½ÖÖ·½Ê½¸÷×ÔµÄÓÅȱµã¡£
ÓÃÐ麯ÊýʵÏÖTemplate MethodµÄ·½Ê½¾Í²»¶à˵ÁË¡£Ó÷ºÐ͵ķ½Ê½ÊµÏÖ¶à̬ÔÚATLÀïÃæÓдóÁ¿µÄÓõ½£¡
·ºÐ͵ ......
access£¨ÅжÏÊÇ·ñ¾ßÓдæÈ¡ÎļþµÄȨÏÞ£©
¡¡¡¡Ïà¹Øº¯Êý stat£¬open£¬chmod£¬chown£¬setuid£¬setgid
¡¡¡¡±íÍ·Îļþ #include<unistd.h>
¡¡¡¡¶¨Ò庯Êý int access(const char * pathname,int mode);
¡¡¡¡º¯Êý˵Ã÷ access()»á¼ì²éÊÇ·ñ¿ÉÒÔ¶Á/дijһÒÑ´æÔÚµÄÎļþ¡£²ÎÊýmodeÓм¸ÖÖÇé¿ö×éºÏ£¬R_OK ......
×î½üÐèҪдһ¶Î³ÌÐò£¬Íê³ÉÒÔÏµĹ¤×÷£¬ÓÃjava½«Êý¾ÝÒÔ¶þ½øÖƵÄÐÎʽдÈëÎļþÖУ¬È»ºóÓÃC¶Á³ö´Ë¶þ½øÖÆÎļþ¡£
¿ªÊ¼µÄʱºòûÓп¼ÂÇ»úÆ÷µÄ×Ö½ÚÐò£¬Ö±½Ó¸ã³ösegment fault.ÏëÁ˺ܾ㬲ÅÃ÷°×ÔÀ´ÊÇjavaºÍCµÄ×Ö½ÚÐòÊDz»Ò»ÑùµÄ¡£
javaÖеÄ×Ö½ÚÐòÊÇbig endianµÄ£¬ËüÊÇÓë»úÆ÷Î޹صġ£¶øcµÄ×Ö»úÐòÊÇ»úÆ÷Ïà¹ØµÄ£¬¶øµ±Ç°ÓõĻúÆ÷ÊÇx84 ......
ÒªÈà Eclipse ¿ÉÒÔ¿ª·¢ C/C++ ³Ìʽ£¬Òª¹ÒÉÏ CDT ²Å¿ÉÒÔ¡£
Ê×ÏÈÒªÏÂÔØCDT
CDTµÄ×îа汾ÊÇ 3.1.0£¬ËüÖ§³Öeclipse3.2.0£¬ÆäÏÂÔصØÖ·£ºhttp://download3.eclipse.org/tools/cdt/releases/callisto/dist/3.1.0/£¬»òÕßÊǵ½http://www.eclipse.org/cdt/downloads.phpÏÂÔØÆäËü° ......
1. ÔõÑù½¨Á¢ºÍÀí½â·Ç³£¸´ÔÓµÄÉùÃ÷£¿ÀýÈ綨ÒåÒ»¸ö°üº¬N ¸öÖ¸Ïò·µ»ØÖ¸Ïò×Ö·ûµÄÖ¸ÕëµÄº¯ÊýµÄÖ¸ÕëµÄÊý×飿
Õâ¸öÎÊÌâÖÁÉÙÓÐÒÔÏÂ3 ÖÖ´ð°¸:
1. char *(*(*a[N])())();
2. ÓÃtypedef Öð²½Íê³ÉÉùÃ÷:
typedef char *pc; /* ×Ö·ûÖ¸Õë*/
typedef pc fpc(); /* ·µ»Ø×Ö·ûÖ¸ÕëµÄº¯Êý*/
typedef fpc *pfpc; /* ÉÏÃ溯ÊýµÄÖ¸Õë*/ ......