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

˳ʱÕë·½·¨ ½â¶Á C ¸´ÔӺ궨Òå

[This was posted to comp.lang.c by its author, David Anderson, on 1994-05-06.]
The ``Clockwise/Spiral Rule''
By David Anderson
There is a technique known as the ``Clockwise/Spiral Rule'' which enables any C programmer to parse in their head any C declaration!
There are three simple steps to follow:
Starting with the unknown element, move in a spiral/clockwise direction; when ecountering the following elements replace them with the corresponding english statements:
[X] or [] => Array X size of... or Array undefined size of... (type1, type2) => function passing type1 and type2 returning... * => pointer(s) to...
Keep doing this in a spiral/clockwise direction until all tokens have been covered.
Always resolve anything in parenthesis first!
Example #1: Simple declaration
+-------+
| +-+ |
| ^ | |
char *str[10];
^ ^ | |
| +---+ |
+-----------+
Question we ask ourselves: What is str?
``str is an...
We move in a spiral clockwise direction starting with `str' and the first character we see is a `[' so, that means we have an array, so...
``str is an array 10 of...
Continue in a spiral clockwise direction, and the next thing we encounter is the `*' so, that means we have pointers, so...
``str is an array 10 of pointers to...
Continue in a spiral direction and we see the end of the line (the `;'), so keep going and we get to the type `char', so...
``str is an array 10 of pointers to char''
We have now ``visited'' every token; therefore we are done!
Example #2: Pointer to Function declaration
+--------------------+
| +---+ |
| |+-+| |
| |^ || |
char *(*fp)( int, float *);
^ ^ ^ || |
| | +--+|


Ïà¹ØÎĵµ£º

C++½Ó¿ÚÓëʵÏÖ·ÖÀëµÄ2ÖÖ·½·¨ (C/C++)

·½·¨Ò»£ºÊ¹ÓÃÁíÒ»¸öʵÏÖÀà·Ö×°ÀàµÄ˽ÓгÉÔ±ºÍº¯Êý£¬ÕâÖÖ·½·¨³ÆÎªPimpl·½·¨¡£
test.h
#pragma once
#include "shared_ptr.hpp"
class CTest
{
public:
    CTest(void);
    ~CTest(void);
    void DoSomething();
private:
& ......

¡¾×ª¡¿¡¾C\C++ÓïÑÔÈëÃÅÆª¡¿ ÉîÈëÖ¸Õë

ÔÙÉÏһƪ£¬ÎÒÃǽéÉÜÁË»ù±¾µ÷ÊÔ¡£Ö®Ç°Ò²ËµÁË£¬Ö®ËùÒ԰ѵ÷ÊÔ·ÅÔÚÇ°Ãæ½²ÊÇÒòΪºóÃæµÄÎÄÕ»ù±¾¶¼»áÓõ½µ÷ÊÔ¡£¹Û²ìÎÒÃǵijÌÐòµ½µ×·¢ÉúÁËʲô¡£ÈÃÎÒÃÇÄܹ»Ö±½ÓÃ÷Á˵Ŀ´Çå³þÎÊÌâµÄ±¾ÖÊ¡£±¾Æª½«ÉîÈëÒ»µã½éÉÜÖ¸ÕëÕâ¸öÈÃÎÞÊý³õѧÕßη¾åµÄ¶«Î÷¡£Ï£Íû´ó¼ÒÔÙ¿´Í걾ƪ֮ºóÄܶÔÖ¸ÕëÓÐеÄÈÏʶ£¬Ö®ºó²»ÔÙ¾åÅÂËü¡£¾õµÃËü¾ÍÄÇô»ØÊ¡£ÄÇÏÂÃæÎÒ ......

¡¾×ª¡¿¡¾C\C++ÓïÑÔÈëÃÅÆª¡¿ HelloWorld˼¿¼

µÚһƪÎÄÕÂÖÕÓÚÂä±ÊÁË£¬±¾ÎĽ«´Ó˼¿¼µÄ½Ç¶ÈÈ¥ÖØÐÂÈÏʶһÏÂHelloworld¡£ÔÚÀý×ÓÖ®ºó»áÌá³ö²»Í¬µÄÎÊÌ⣬Òýµ¼´ó¼Òȥ˼¿¼Ã¿Ò»¾äÄËÖÁÿ¸öϸ½Ú¡£Í¬Ê±Ï£ÍûÄܹ»Èôó¼ÒÒÔºóÄܹ»ÒÔ²»¶Ï˼¿¼²»¶ÏÌáÎʵķ½Ê½È¥¿´´ý×Ô¼ºµÄ³ÌÐò¡£ÎÒÏàÐÅ´ó¼Ò»á·¢ÏֺܶàÐµĶ«Î÷£¬ºÃÁËÇÐÈëÕýÌâ¡£
ÎÒÃÇÿѧһÖÖеÄÓïÑÔ»ù±¾¶¼»á´Óhelloworld¿ªÊ¼£¬»ù±¾Ã¿ÖÖÓïÑÔ ......

¡¾×ª¡¿C\C++Ìõ¼þ£¨ÈýÄ¿£©ÔËËã·ûÇÉÃîÔ­Àí½âÎö

×î½üÒ»Ö±Ñо¿Ò»¸ö¶Ô¸öÈ˶øÑÔºÜÓмÛÖµµÄÒ»¸öLIB¿âµÄÄæÏò¡£ÔÚ½ñÌìϰàºóͻȻÁé¸ÐÉÁÏÖ£¬Õâ¸ö¶Ï¶ÏÐøÐøÄæÁ˽ӽüÒ»ÖܵĺËÐĹÜÀíÀà¡£ÖÕÓÚÔÚ½ñÌì¸øÄæÍêÁË¡£ÔÚ×îºóÒ»¸öº¯ÊýÀÅöµ½ÁË֮ǰ»ù±¾Ã»ÓÐÓùýµÄÒ»ÌõÖ¸Áî¡££¨ºÇºÇ£¬¸ßÊÖ¼ûЦÁË£¡£©µ±È»¹â¿´µ¥¾äµÄ»ã±àÖ¸ÁÊÇûÓа취¿´³ö¾ßÌåµÄ×÷Óõ쬶øÇÒ»¹ºÜ¿ÉÄÜ»áÈÏΪԭ×÷Õß±¾À´¾ÍÊÇÓû㱠......

Ò»¸öÓÐȤµÄc³ÌÐò

-------------------------
--------------------------------------
--------------------------------------
viki 2010.1.25 ÖÆ×÷ ³ÌÐòÀïµÄ´ð°¸ÎªY
===================================
³ÌÐò½øÈ¥ºó£¬ÏÈÊäÈë16¸öÊýÿ¸öÊý°´»Ø³µ¡£
È»ºóÉú³ÉÒ»¸ö4x4µÄÊý×飬
ÈùÛÖÚ˵³öÐÄÖÐÏëµÄÊýµÄÅÅÊý£¬
½Ó×ųÌÐò»á½«Õâ´®Êý×éµÄÐÐ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ