{"id":5697,"date":"2024-09-05T11:01:01","date_gmt":"2024-09-05T03:01:01","guid":{"rendered":""},"modified":"2024-09-05T11:01:01","modified_gmt":"2024-09-05T03:01:01","slug":"C++\u7684\u8bcd\u6cd5\u95ed\u5305_c++\u57fa\u672c\u8bed\u6cd5","status":"publish","type":"post","link":"https:\/\/mushiming.com\/5697.html","title":{"rendered":"C++\u7684\u8bcd\u6cd5\u95ed\u5305_c++\u57fa\u672c\u8bed\u6cd5"},"content":{"rendered":"

C++\u7684\u8bcd\u6cd5\u95ed\u5305<\/p>\n

Thomas M. Breuel[1]<\/p>\n

\u7ffb\u8bd1\uff1a\u5434\u6656<\/p>\n

\u6458\u8981<\/p>\n

\u6211\u4eec\u63cf\u8ff0C++\u7f16\u7a0b\u8bed\u8a00\u7684\u4e00\u4e2a\u5141\u8bb8\u51fd\u6570\u5b9a\u4e49\u5d4c\u5957\uff0c\u5e76\u63d0\u4f9b\u5177\u6709\u52a8\u6001\u751f\u547d\u671f\u7684\u8bcd\u6cd5\u95ed\u5305\uff08lexical closures\uff09\u7684\u6269\u5c55\u3002<\/p>\n

\u5bf9\u4e8e\u8fd9\u4e2a\u6269\u5c55\uff0c\u6211\u4eec\u7684\u4e3b\u8981\u52a8\u529b\u662f\u5b83\u5141\u8bb8\u7a0b\u5e8f\u5458\uff0c\u50cf\u6210\u5458\u51fd\u6570\u90a3\u4e48\u7b80\u5355\u5730\uff0c\u4e3a\u96c6\u5408\u7c7b\uff08collection class\uff09\u5b9a\u4e49\u8fed\u4ee3\u5668\u3002\u8fd9\u6837\u7684\u8fed\u4ee3\u5668\u63a5\u53d7\u51fd\u6570\u6307\u9488\u6216\u95ed\u5305\u4f5c\u4e3a\u53c2\u6570\uff1b\u63d0\u4f9b\u8bcd\u6cd5\u95ed\u5305\u4f7f\u8868\u8fbe\u72b6\u6001\uff08\u4f8b\u5982\uff0c\u7d2f\u52a0\u5668\uff09\u81ea\u7136\u4e14\u5bb9\u6613\u3002\u8fd9\u4e2a\u6280\u672f\u5728\u50cfScheme\uff0cT\u6216Smalltalk-80\u7684\u7f16\u7a0b\u8bed\u8a00\u91cc\u662f\u53f8\u7a7a\u89c1\u60ef\u7684\uff0c\u5e76\u4e14\u5728\u9762\u5411\u5bf9\u8c61\u7f16\u7a0b\u8bed\u8a00\u4e2d\uff0c\u53ef\u80fd\u662f\u63d0\u4f9b\u901a\u7528\u8fed\u4ee3\u7ed3\u6784\u6700\u7b80\u6d01\u4e0e\u81ea\u7136\u7684\u65b9\u5f0f\u3002\u5d4c\u5957\u51fd\u6570\u5b9a\u4e49\u7684\u80fd\u529b\u8fd8\u9f13\u52b1\u4e00\u4e2a\u6a21\u5757\u5316\u7684\u7f16\u7a0b\u98ce\u683c\u3002 <\/p>\n

\u6211\u4eec\u60f3\u8981\u4ee5\u8fd9\u4e2a\u65b9\u5f0f\u6269\u5c55C++\u8bed\u8a00\uff0c\u65e0\u9700\u4e3a\u95ed\u5305\u5f15\u5165\u65b0\u7684\u6570\u636e\u7c7b\u578b\uff0c\u800c\u4e14\u4e0d\u5f71\u54cd\u4e0d\u4f7f\u7528\u8fd9\u4e2a\u7279\u6027\u7684\u7a0b\u5e8f\u7684\u6548\u7387\u3002\u4e3a\u4e86\u505a\u5230\u8fd9\u4e00\u70b9\uff0c\u6211\u4eec\u5efa\u8bae\u5728\u6784\u5efa\u4e00\u4e2a\u95ed\u5305\u65f6\uff0c\u4ea7\u751f\u4e00\u5c0f\u6bb5\u4ee3\u7801\u8f7d\u5165\u9759\u6001\u94fe\u6307\u9488\uff0c\u5e76\u8df3\u8f6c\u5230\u51fd\u6570\u4f53\u3002\u4e00\u4e2a\u95ed\u5305\u662f\u6307\u5411\u8fd9\u5c0f\u6bb5\u4ee3\u7801\u7684\u6307\u9488\u3002\u8fd9\u4e2a\u6280\u5de7\u5141\u8bb8\u50cf\u5904\u7406\u4e00\u4e2a\u6307\u5411\u4e0d\u5f15\u7528\u4efb\u4f55\u975e\u5c40\u90e8\u3001\u975e\u5168\u5c40\u53d8\u91cf\u7684\u666e\u901aC++\u51fd\u6570\u7684\u6307\u9488\u90a3\u6837\u5904\u7406\u95ed\u5305\u3002<\/p>\n

\u6211\u4eec\u8ba8\u8bba\u4e0e\u73b0\u5b58\u7684\u4f5c\u7528\u57df\u89c4\u5219\u3001\u8bed\u6cd5\u3001\u5206\u914d\u7b56\u7565\u3001\u53ef\u79fb\u690d\u6027\u53ca\u6548\u7387\u7684\u76f8\u5bb9\u6027\u95ee\u9898\u3002<\/p>\n

1 \u6211\u4eec\u8981\u6dfb\u52a0\u4ec0\u4e48\u2026\u2026\u53ca\u4e3a\u4ec0\u4e48<\/h2>\n

\u6211\u4eec\u5e0c\u671b\u80fd\u5728C++\u7a0b\u5e8f\u4e2d\u5d4c\u5957\u51fd\u6570\u5b9a\u4e49\u3002\u5728\u672c\u8282\u4e2d\uff0c\u6211\u4eec\u5c06\u8ba8\u8bba\u4e3a\u4ec0\u4e48\u5d4c\u5957\u51fd\u6570\u5b9a\u4e49\u7684\u80fd\u529b\u662f\u671f\u671b\u7684\u82e5\u5e72\u539f\u56e0\u3002\u51e0\u4e4e\u6240\u6709\u5176\u5b83\u73b0\u4ee3\u7a0b\u5e8f\u8bed\u8a00\uff0c\u6bd4\u5982Scheme\uff0cT\uff0cSmalltalk-80\uff0cCommon Lisp\uff0cPascal\uff0cModula-2\u53caAda\uff0c\u90fd\u63d0\u4f9b\u8fd9\u4e2a\u529f\u80fd\u3002<\/p>\n

\u4e3a\u4e86\u5c55\u793a\u8fd9\u4e2a\u8bed\u8a00\u7279\u6027\u7684\u529f\u7528\uff0c\u6211\u4eec\u5fc5\u987b\u5728\u8bed\u6cd5\u4e0a\u8fbe\u6210\u4e00\u81f4\u3002\u4e3a\u4e86\u5728\u53e6\u4e00\u4e2a\u51fd\u6570\u5185\u8868\u793a\u4e00\u4e2a\u51fd\u6570\u7684\u5b9a\u4e49\uff0c\u6211\u4eec\u5c06\u7b80\u5355\u5730\u79fb\u52a8\u5b83\u7684\u5b9a\u4e49\u5230\u90a3\u4e2a\u51fd\u6570\u91cc\uff0c\u4f46\u5728\u5176\u5b83\u65b9\u9762\u4e0e\u5168\u5c40\u57df\u7684\u51fd\u6570\u76f8\u540c\u3002\u4f8b\u5982\uff0c\u4e0b\u9762\u7684\u4ee3\u7801\u7247\u6bb5\u5728function1(int)\u5185\u5b9a\u4e49\u4e86function2(int)\uff1a<\/p>\n

function1(int x) {
\n <\/p>\n

    \/\/ ...<\/p>\n

    function2(inty) {
\n <\/p>\n

         \/\/...<\/p>\n

    }<\/p>\n

    \/\/ ...<\/p>\n

}<\/p>\n

\u9664\u975efunction2\u81ea\u5df1\u58f0\u660e\u6807\u8bc6\u7b26x\uff0c\u5728function2\u4e2d\u63d0\u5230\u7684x\u5c06\u5f15\u7528function1\u7684\u5b9e\u53c2\u3002<\/p>\n

\u4e3a\u4e86\u5141\u8bb8\u5728\u5185\u90e8\u8bcd\u6cd5\u5c42\u6b21\u76f8\u4e92\u9012\u5f52\u7684\u51fd\u6570\u7684\u5b9a\u4e49\uff0c\u63d0\u4f9b\u67d0\u4e2a\u65b9\u5f0f\u6765\u58f0\u660e\u6ca1\u6709\u5b9a\u4e49\u5728\u5168\u5c40\u5c42\u6b21\u7684\u51fd\u6570\u662f\u5fc5\u8981\u7684\u3002\u6211\u4eec\u5efa\u8bae\u901a\u8fc7\u5411\u51fd\u6570\u58f0\u660e\u6dfb\u52a0\u5173\u952e\u5b57auto\u4f5c\u4e3a\u524d\u7f00\u6765\u5b9e\u73b0\u3002\u76ee\u524d\uff0c\u5728\u4e00\u4e2a\u51fd\u6570\u58f0\u660e\u4e4b\u524d\u4f7f\u7528\u5173\u952e\u5b57auto\u662f\u975e\u6cd5\u7684\u3002\u56e0\u6b64\uff0c\u8fd9\u79cd\u6269\u5c55\u662f\u517c\u5bb9\u7684\u3002<\/p>\n

1.1 \u5d4c\u5957\u4e0e\u6a21\u5757\u5316<\/h3>\n

\u5d4c\u5957\u51fd\u6570\u5b9a\u4e49\u7684\u80fd\u529b\u9f13\u52b1\u7a0b\u5e8f\u7684\u6a21\u5757\u5316\u8bbe\u8ba1\u3002\u5b83\u5141\u8bb8\u7a0b\u5e8f\u5458\u628a\u4ec5\u7531\u4e00\u4e2a\u51fd\u6570\u4f7f\u7528\u7684\u51fd\u6570\u53ca\u53d8\u91cf\u4fdd\u7559\u5728\u8be5\u51fd\u6570\u5c40\u90e8\u3002\u5728C\u91cc\uff0c\u8fd9\u6837\u7684\u6a21\u5757\u5316\u4ec5\u5728\u6587\u4ef6\u5c42\u6b21\u662f\u53ef\u80fd\u7684\uff1a\u4e00\u4e2a\u51fd\u6570\u6807\u8bc6\u7b26\u7684\u4f5c\u7528\u57df\u53ef\u4ee5\u901a\u8fc7\u628a\u5b83\u58f0\u660e\u4e3astatic\uff0c\u9650\u5236\u5728\u4e00\u4e2a\u6587\u4ef6\u4e2d\u3002\u4e00\u4e2a\u5728\u51fd\u6570\u95f4\u5171\u4eab\u7684\u53d8\u91cf\u6807\u8bc6\u7b26\u7684\u4f5c\u7528\u57df\u5fc5\u5b9a\u5305\u542b\u81f3\u5c11\u4e00\u4e2a\u7f16\u8bd1\u5355\u5143\uff0c\u56e0\u4e3a\u5b83\u5fc5\u987b\u5728\u5168\u5c40\u5c42\u6b21\u58f0\u660e\u3002C++\u652f\u6301\u9650\u5b9a\u67d0\u79cd\u51fd\u6570\u53ca\u53d8\u91cf\u6807\u8bc6\u7b26\u7684\u4f5c\u7528\u57df\uff0c\u901a\u8fc7\u4f7f\u8fd9\u4e9b\u51fd\u6570\u53ca\u53d8\u91cf\u6210\u4e3a\u4e00\u4e2a\u7c7b\u7684\u6210\u5458\u3002<\/p>\n

\u4e0d\u8fc7\uff0c\u5f15\u5165\u4e00\u4e2a\u65b0\u7684\u7c7b\u53ea\u662f\u4e3a\u4e86\u9650\u5b9a\u4e00\u4e2a\u6807\u8bc6\u7b26\u7684\u4f5c\u7528\u57df\u901a\u5e38\u662f\u4e0d\u81ea\u7136\u7684\u3002\u4f8b\u5982\uff0c\u8003\u8651\u5806\u6392\u5e8f\u7b97\u6cd5\u3010Wir79\u3011\u3002\u5b83\u5305\u542b\u4e00\u4e2a\u53cd\u590d\u8c03\u7528sift\u51fd\u6570\u5411\u5806\u63d2\u5165\u5143\u7d20\u7684\u6392\u5e8f\u51fd\u6570\u3002\u5728C\u6216C++\u4e2d\uff0c\u6211\u4eec\u5c06\u5982\u4e0b\u8868\u793a\uff1a<\/p>\n

sift(int* v,int x,int l,int r) {
\n <\/p>\n

     \/\/insert x into the heap<\/p>\n

     \/\/formed by elements l...r of v<\/p>\n

}<\/p>\n

\/\/ sort an array of integers v<\/p>\n

\/\/ v is n elements long<\/p>\n

heapsort(int* v,int n) {
\n <\/p>\n

     \/\/ codethat calls sift<\/p>\n

}<\/p>\n

\u7136\u800c\u8fd9\u4e0d\u662f\u4ee4\u4eba\u6ee1\u610f\u7684\uff0c\u56e0\u4e3a\u51fd\u6570sift\u4e0d\u592a\u53ef\u80fd\u7528\u5728\u7a0b\u5e8f\u7684\u5176\u5b83\u5730\u65b9\u3002\u51fd\u6570sift\u5e94\u8be5\u4ec5\u5728\u51fd\u6570heapsort\u5185\u53ef\u89c1\u3002\u53e6\u5916\uff0c\u6211\u4eec\u5e0c\u671b\u5728sift\u91cc\u5f15\u7528\u53d8\u91cfv\uff0c\u800c\u65e0\u9700\u628a\u5b83\u4f20\u9012\u4e3a\u4e00\u4e2a\u53c2\u6570\u3002\u5d4c\u5957\u5141\u8bb8\u6211\u4eec\u91cd\u5199\u4e3a\uff1a<\/p>\n

\/\/ sort an array of integers v<\/p>\n

\/\/ v is n elements long<\/p>\n

heapsort(int* v,int n) {
\n <\/p>\n

     sift(intx,int l,int r) {
\n <\/p>\n

         \/\/insert x into the heap<\/p>\n

         \/\/ formed by elements l...r of v<\/p>\n

     }<\/p>\n

     \/\/ codethat calls sift<\/p>\n

}<\/p>\n

\u7279\u522b\u6ce8\u610f\u5728\u51fd\u6570sift\u4e2d\u6807\u8bc6\u7b26v\u7684\u4f7f\u7528\u63f4\u5f15\u8bcd\u6cd5\u4e0a\u5c01\u88c5\u51fd\u6570heapsort\u7684\u5b9e\u53c2v[2]\u3002<\/p>\n

\u4f5c\u4e3a\u53e6\u4e00\u4e2a\u4f8b\u5b50\uff0c\u5047\u5b9a\u6211\u4eec\u6709\u51fd\u6570integrate\u6c42\u4e00\u4e2a\u7ed9\u5b9a\u51fd\u6570\u5728\u4e24\u4e2a\u8fb9\u754c\u95f4\u7684\u79ef\u5206\uff0c\u5e76\u4e14\u6211\u4eec\u5e0c\u671b\u5bf9\u4e00\u4e2a\u53c2\u6570\u5316\u51fd\u6570\u65cf\u6c42\u79ef\u5206\u3002\u540c\u6837\uff0c\u6700\u81ea\u7136\u7684\u8868\u8fbe\u65b9\u5f0f\u5982\u4e0b\uff1a<\/p>\n

integrate_all(int n,double* as,double *bs,double*cs,double eps) {
\n <\/p>\n

     doubleintegrate(double low,double high,<\/p>\n

                                doubleepsilon,double (*f)(double));<\/p>\n

     double a,b,c;<\/p>\n

     doublef(double x) {
\n <\/p>\n

          returna*x*x+b*x+c;<\/p>\n

     }<\/p>\n

     for(inti=0;i<n;i++) {
\n <\/p>\n

          a=as[i];b=bs[i]; c=cs[i];<\/p>\n

          printf(\"a: %g, b: %g, c: %g, i:%g\\n\",<\/p>\n

                      a,b,c,integrate(0.0,1.0,eps,f));<\/p>\n

    }<\/p>\n

}<\/p>\n

1.2 \u8fed\u4ee3\u5668<\/h3>\n

\u5d4c\u5957\u51fd\u6570\u5b9a\u4e49\u4e0e\u5f15\u7528\u88ab\u5c01\u95ed\u5757\u58f0\u660e\u7684\u53d8\u91cf\u7684\u80fd\u529b\uff0c\u8fde\u540c\u6574\u4e2a\u96c6\u5408\u7c7b\u4e0a\u7684\u8fed\u4ee3\u5668\uff0c\u662f\u7279\u522b\u6709\u7528\u7684\u3002\u8003\u8651\u4e0b\u9762\u7b80\u5355\u7684\u96c6\u5408\u7c7b\uff1a<\/p>\n

class BagOfInts {
\n <\/p>\n

public:<\/p>\n

     \/\/ addan int to the collection<\/p>\n

     voidadd(int);<\/p>\n

     \/\/ testwhether an int<\/p>\n

     \/\/ isin the collection<\/p>\n

     intmember(int);<\/p>\n

     \/\/apply a function to every<\/p>\n

     \/\/ element in the collection<\/p>\n

     voidwalk(void (*)(int));<\/p>\n

};<\/p>\n

\u4f8b\u5982\uff0c\u8981\u5728\u4e00\u4e2a\u5305\u4e2d\u6253\u5370\u6240\u6709\u7684\u5143\u7d20\uff0c\u6211\u4eec\u5728\u6807\u51c6C++\u91cc\u8fd9\u6837\u505a\uff1a<\/p>\n

printit(int x) {
\n <\/p>\n

     printf(\"integer in bag:%d\\n\",x);<\/p>\n

}<\/p>\n

main() {
\n <\/p>\n

     BagOfIntsaBag;<\/p>\n

      ...<\/p>\n

      aBag.walk(printit);<\/p>\n

}<\/p>\n

\u6ce8\u610f\u6211\u4eec\u88ab\u8feb\u5728\u8fdc\u79bb\u5b83\u5b9e\u9645\u4f7f\u7528\u7684\u5730\u65b9\u5b9a\u4e49\u51fd\u6570printit\u3002\u6211\u4eec\u4e3a\u4ec0\u4e48\u4f7fprintit\u6210\u4e3a\u6446\u5728\u9996\u4f4d\u51fd\u6570\u7684\u539f\u56e0\uff0c\u4e0d\u662f\u56e0\u4e3a\u5b83\u662f\u67d0\u4e2a\u8fdb\u7a0b\u6709\u7528\u7684\u62bd\u8c61\uff0c\u4e5f\u4e0d\u662f\u56e0\u4e3a\u6211\u4eec\u5c06\u5728\u51e0\u4e2a\u5730\u65b9\u4f7f\u7528\u5b83\u3002\u53ea\u662f\u56e0\u4e3a\u6210\u5458\u51fd\u6570walk\u8981\u6c42\u4e00\u4e2a\u51fd\u6570\u6307\u9488\u4f5c\u4e3a\u53c2\u6570\u3002\u66f4\u4e3a\u607c\u4eba\u7684\u662f\uff0c\u5728\u6807\u51c6C++\u91cc\uff0c\u4f5c\u4e3a\u8fed\u4ee3\u5668\u53c2\u6570\u4f20\u9012\u7684\u4e00\u4e2a\u51fd\u6570\u4ec5\u80fd\u5bf9\u9759\u6001\u53d8\u91cf\u6216\u5168\u5c40\u53d8\u91cf\u8d77\u4f5c\u7528\u3002\u5982\u679c\u6211\u4eec\u5e0c\u671b\u4f7f\u7528\u8fed\u4ee3\u5668walk\u6c47\u603b\u4e00\u4e2a\u5305\u91cc\u7684\u6240\u6709\u5143\u7d20\uff0c\u6211\u4eec\u5fc5\u987b\u4f7f\u7528\u4e00\u4e2a\u5168\u5c40\u53d8\u91cf\uff1a<\/p>\n

int xxx_counter;<\/p>\n

int xxx_count(int x) {
\n <\/p>\n

     xxx_counter+=x;<\/p>\n

}<\/p>\n

fizzle() {
\n <\/p>\n

    BagOfIntsaBag;<\/p>\n

    ...<\/p>\n

    xxx_counter=0;<\/p>\n

    aBag.walk(xxx_count);<\/p>\n

    intsum=xxx_counter;<\/p>\n

     ...<\/p>\n

}<\/p>\n

\u5982\u679c\u5141\u8bb8\u6211\u4eec\u5d4c\u5957\u51fd\u6570\u5b9a\u4e49\uff0c\u6211\u4eec\u53ef\u4ee5\u628a\u8fd9\u7b80\u5355\u5730\u8868\u793a\u4e3a\uff1a<\/p>\n

fizzle() {
\n <\/p>\n

    BagOfIntsaBag;<\/p>\n

     ...<\/p>\n

     intsum=0;<\/p>\n

     count(intx) {
\n <\/p>\n

         sum+=x;<\/p>\n

     }<\/p>\n

     aBag.walk(count);<\/p>\n

     ...<\/p>\n

}<\/p>\n

\u73b0\u5728\uff0c\u6240\u6709\u7684\u6807\u8bc6\u7b26\u5c31\u88ab\u58f0\u660e\u53ca\u5b9a\u4e49\u5728\u4f7f\u7528\u5b83\u4eec\u7684\u5730\u65b9\u3002\u6ca1\u6709\u51fa\u73b0\u5728\u5168\u5c40\u4f5c\u7528\u57df\u7684\u6807\u8bc6\u7b26\u662f\u4e0d\u5e94\u8be5\u5728\u5168\u5c40\u4f5c\u7528\u57df\u53ef\u89c1\u7684[3]\u3002\u5e76\u4e14\u8ba1\u6570\u5668\u6ca1\u6709\u6d6a\u8d39\u5168\u5c40\u6570\u636e\u7a7a\u95f4\uff1b\u7528\u4e8e\u8ba1\u6570\u5668\u7684\u7a7a\u95f4\u4ec5\u5f53\u51fd\u6570fizzle\u6d3b\u52a8\u65f6\u624d\u5b58\u5728\u3002<\/p>\n

\u4e3a\u7528\u6237\u5b9a\u4e49\u7c7b\u7f16\u5199\u8fed\u4ee3\u5668\u7684\u8fd9\u4e2a\u505a\u6cd5\uff0c\u5728Smalltalk\u4e0e\u7c7bLisp\u8bed\u8a00\u4e2d\uff0c\u5b9e\u9645\u4e0a\u975e\u5e38\u5e38\u89c1\u3002\u4f8b\u5982\uff0c\u5728Smalltalk-80\u3010GR83\u3011\uff0c\u91cc\uff0c\u6211\u4eec\u53ef\u4ee5\u5982\u4e0b\u8868\u8fbe\u51fd\u6570fizzle\uff1a<\/p>\n

fizzle<\/p>\n

    | sum |<\/p>\n

     ...<\/p>\n

     sum<- 0.<\/p>\n

     aBagdo: [x | sum <- sum + x].<\/p>\n

     ...<\/p>\n

\u800c\u5728CommonLisp\u3010Ste84\u3011\u91cc\uff0c\u6211\u4eec\u53ef\u4ee5\u5199\u4f5c\uff1a<\/p>\n

(define fizzle ()<\/p>\n

     (let((aBag ...)<\/p>\n

             (sum 0))<\/p>\n

          ...<\/p>\n

         (mapnil #'(lambda (x) (incf sum x)))<\/p>\n

          ...))<\/p>\n

\u8bfb\u8005\u53ef\u80fd\u4f1a\u95ee\u4f7f\u7528\u6807\u51c6C++\u6784\u9020\u662f\u5426\u6709\u66ff\u6362\u7684\u505a\u6cd5\u3001\u6211\u4eec\u5f88\u5feb\u5c06\u63cf\u8ff0\u5176\u4e2d\u4e4b\u4e00\u3002\u4e0d\u8fc7\u8ba9\u6211\u4eec\u9996\u5148\u63d0\u9192\u81ea\u5df1\uff0c\u5728\u4efb\u4f55\u8bed\u8a00\u4e2d\u6211\u4eec\u8981\u6c42\u4ec0\u4e48\u6837\u7684\u8fed\u4ee3\u5668\u6784\u9020\u3002<\/p>\n

\u4e00\u4e2a\u8fed\u4ee3\u5668\u57fa\u672c\u4e0a\u662f\u63a5\u53d7\u4e00\u6bb5\u4ee3\u7801\uff0c\u53cd\u590d\u8c03\u7528\u5b83\uff0c\u5e76\u6539\u53d8\u8fd9\u6bb5\u4ee3\u7801\u73af\u5883\u4e2d\u67d0\u4e9b\u7ed1\u5b9a\u7684\u503c\u7684\u6784\u9020\u3002\u6839\u636eC\u53caC++\u5185\u7f6e\u7684\u8fed\u4ee3\u5668\uff0c\u6211\u4eec\u4e60\u60ef\u4e0a\u5e94\u8be5\u80fd\u505a\u5230\u4ee5\u4e0b\u3002<\/p>\n

    \n
  1. \u5728\u6e90\u4ee3\u7801\u4e2d\u8fed\u4ee3\u5668\u8981\u6267\u884c\u7684\u5730\u65b9\uff0c\u6211\u4eec\u53ef\u4ee5\u5199\u4e0b\u8fd9\u6bb5\u8981\u53cd\u590d\u6267\u884c\u7684\u4ee3\u7801\u3002<\/li>\n
  2. \u8fd9\u6bb5\u53cd\u590d\u6267\u884c\u7684\u4ee3\u7801\u53ef\u4ee5\u5f15\u7528\u4f5c\u7528\u57df\u9650\u5236\u5728\u8fd9\u4e2a\u5c01\u88c5\u51fd\u6570\u5185\u7684\u6807\u8bc6\u7b26\u3002<\/li>\n
  3. \u7531\u8fd9\u4e2a\u8fed\u4ee3\u6784\u9020\u4fee\u6539\u7684\u53d8\u91cf\u540d\u53ef\u4ee5\u81ea\u7531\u9009\u62e9\u3002<\/li>\n<\/ol>\n

    \u8fd9\u4e9b\u5c5e\u6027\u662f\u5185\u7f6e\u8fed\u4ee3\u5668\u975e\u5e38\u6709\u7528\u7684\u7279\u6027\uff0c\u5bf9\u4e8e\u7528\u6237\u5b9a\u4e49\u64cd\u4f5c\u7b26\u653e\u5f03\u5b83\u4eec\u4e4b\u4e00\u5c06\u662f\u5341\u5206\u9057\u61be\u7684\u3002<\/p>\n

    \u5b9e\u73b0\u8fd9\u4e9b\u76ee\u6807\u7684\u4e00\u4e2a\u65b9\u5f0f\u662f\u5f15\u5165\u4e00\u4e2a\u65b0\u7684\u7c7b\u8fde\u540c\u4e00\u4e2a\u5b8f\uff0c\u5c31\u50cf\u5982\u4e0b\uff1a<\/p>\n

    class BagOfIntsStepper {
    \n <\/p>\n

    public:<\/p>\n

         intmore();<\/p>\n

         intnext();<\/p>\n

    };<\/p>\n

    #define iterateBagOfInts(bag,var) \\<\/p>\n

    for(BagOfIntsStepper stepper=bag.makeStepper(); \\<\/p>\n

         stepper.more();\\<\/p>\n

         var=stepper.next())<\/p>\n

    \u8fd9\u4e2a\u6784\u9020\u4e0d\u4f1a\u7834\u574f\u4e0a\u8ff0\u4efb\u4f55\u7684\u9650\u5236\u3002\u4e0d\u8fc7\uff0c\u5b83\u6709\u51e0\u4e2a\u574f\u5904\u3002\u5b83\u8981\u6c42\u6211\u4eec\u4e3a\u8868\u8fbe\u8fed\u4ee3\u7684\u76ee\u7684\u5f15\u5165\u4e00\u4e2a\u65b0\u7684\u7c7b\uff0c\u8981\u6c42\u6bcf\u4e2a\u8fed\u4ee3\u6b65\u9aa4\u5bf9\u6210\u5458\u51fd\u6570\u7684\u4e24\u4e2a\u8c03\u7528\uff0c\u5e76\u4e14\u8981\u6c42\u6211\u4eec\u5b9a\u4e49\u4e00\u4e2a\u5b8f\u3002\u4e0d\u8fc7\u6700\u91cd\u8981\u7684\uff0c\u6211\u4eec\u4e0d\u559c\u6b22\u5b83\u5728\u4e8e\u5f53\u6211\u4eec\u5e0c\u671b\u4f7f\u7528\u76f8\u540c\u7684\u57fa\u7c7b[4]\u8fed\u4ee3\u4e0d\u540c\u7684\u6536\u96c6\u7c7b\u65f6\uff0c\u5b83\u96be\u4ee5\u6269\u5c55\u3002\u4f8b\u5982\uff0c\u6211\u4eec\u53ef\u80fd\u8fd8\u6709\u4e00\u4e2a\u7c7bSetOfInts\u3002\u5982\u679c\u6211\u4eec\u4f7f\u7528walk\u5f62\u5f0f\u7684\u8fed\u4ee3\u7ed3\u6784\uff0c\u6211\u4eec\u53ef\u4ee5\u7b80\u5355\u5730\u4f7fBagOfInts\u4e0eSetOfInts\u6210\u4e3a\u7c7bCollectionOfInts\u7684\u5b50\u7c7b\uff0c\u5e76\u628awalk\u58f0\u660e\u4e3a\u865a\u62df\u51fd\u6570\u3002\u4f7f\u7528\u4e00\u4e2a\u6b65\u8fdb\uff08stepper\uff09\u7c7b\u5b9e\u73b0\u76f8\u540c\u7684\u6548\u679c\u8981\u8fdc\u6ca1\u6709\u90a3\u4e48\u76f4\u89c2\uff0c\u5e76\u4e14\u53ef\u80fd\u8981\u6c42\u6bcf\u4e2a\u8fed\u4ee3\u6b65\u9aa4\u4e24\u4e2a\u865a\u62df\u51fd\u6570\u8c03\u7528\u7684\u989d\u5916\u5f00\u9500\u3002<\/p>\n

    2 \u5982\u4f55\u5b9e\u73b0<\/h2>\n

    \u4e3a\u4e86\u5728C++\u4e2d\u5b9e\u73b0\u5d4c\u5957\u4e0e\u8bed\u6cd5\u95ed\u5408\uff0c\u6211\u4eec\u5fc5\u987b\u5f15\u5165\u4e00\u4e2a\u9759\u6001\u94fe\uff0c\u4e3a\u8bcd\u6cd5\u4e0a\u95ed\u5408\u7684\u51fd\u6570\uff08\u672f\u8bed\u53c2\u8003\u3010AU79\u3011\u4e0e\u3010Wir77\u3011\uff09\u628a\u6bcf\u4e2a\u6d3b\u52a8\u8bb0\u5f55\u94fe\u63a5\u5230\u5f53\u524d\u6d3b\u52a8\u8bb0\u5f55\u3002\u5f53\u6211\u4eec\u8c03\u7528\u4e00\u4e2a\u51fd\u6570\u65f6\uff0c\u6211\u4eec\u4e0d\u4ec5\u5fc5\u987b\u77e5\u9053\u5b83\u7684\u5730\u5740\uff0c\u6211\u4eec\u8fd8\u8981\u4e3a\u8bcd\u6cd5\u4e0a\u95ed\u5408\u7684\u51fd\u6570\u4f20\u9012\u6307\u5411\u5f53\u524d\u6d3b\u52a8\u8bb0\u5f55\u7684\u4e00\u4e2a\u6307\u9488\u3002\u4e0d\u8fc7\uff0c\u5bf9\u4e8e\u8fd9\u4e2a\u89c4\u5219\u6709\u4e24\u4e2a\u4f8b\u5916\u3002<\/p>\n

    \u5728\u5168\u5c40\u57df\u5b9a\u4e49\u7684\u51fd\u6570\u7684\u6d3b\u52a8\u8bb0\u5f55\u4e2d\uff0c\u4e0d\u9700\u8981\u4fdd\u7559\u4e00\u4e2a\u9759\u6001\u94fe\u6307\u9488\u7684\u7a7a\u95f4\uff0c\u56e0\u4e3a\u5176\u8bcd\u6cd5\u73af\u5883\u5df2\u77e5\u662f\u5168\u5c40\u73af\u5883\uff0c\u5e76\u4e14\u4e00\u4e2a\u6807\u8bc6\u7b26\u662f\u5426\u63f4\u5f15\u4e00\u4e2a\u5168\u5c40\u53d8\u91cf\uff0c\u5728\u7f16\u8bd1\u65f6\u523b\u662f\u6e05\u695a\u7684\u3002<\/p>\n

    \u53e6\u5916\uff0c\u4e00\u4e2a\u5b9a\u4e49\u5728\u5168\u5c40\u57df\u7684\u51fd\u6570\u4e0d\u9700\u8981\u5411\u8bcd\u6cd5\u95ed\u5408\u73af\u5883\u4f20\u9012\u4e00\u4e2a\u6307\u9488\uff0c\u56e0\u4e3a\u8fd9\u4e2a\u8bcd\u6cd5\u95ed\u5408\u73af\u5883\u662f\u5168\u5c40\u73af\u5883\uff0c\u5b83\u662f\u552f\u4e00\u4e14\u5177\u6709\u4e00\u4e2a\u5df2\u77e5\u7684\u5730\u5740\u3002<\/p>\n

    \u8fd9\u4e24\u4e2a\u4f8b\u5916\u8fde\u540cC++\u4ec5\u5141\u8bb8\u5728\u5168\u5c40\u57df\u5b9a\u4e49\u51fd\u6570\u8fd9\u4e2a\u4e8b\u5b9e\uff0c\u4f7f\u5f97\u5728C++\u91cc\u5b9e\u73b0\u8bcd\u6cd5\u4f5c\u7528\u57df\uff0c\u800c\u4e0d\u9700\u8981\u4f7f\u7528\u4e00\u4e2a\u8868\u9732\uff0c\u4e00\u4e2a\u9759\u6001\u94fe\uff0c\u6216\u5411\u73af\u5883\u4f20\u9012\u6307\u9488\uff0c\u6210\u4e3a\u53ef\u80fd\u3002<\/p>\n

    \u5411\u6ca1\u6709\u5b9a\u4e49\u5728\u5168\u5c40\u57df\u7684\u51fd\u6570\u7684\u6d3b\u52a8\u8bb0\u5f55\u6dfb\u52a0\u9759\u6001\u94fe\u7684\u7a7a\u95f4\u662f\u4e0d\u91cd\u8981\u7684\uff08\u53ef\u4ee5\u7b80\u5355\u5730\u8ba4\u4e3a\u5b83\u4eec\u662f\u989d\u5916\u7684\u81ea\u52a8\u53d8\u91cf\uff09\u3002\u56e0\u4e3a\u7f16\u8bd1\u5668\u603b\u662f\u77e5\u9053\u4e00\u4e2a\u6d3b\u52a8\u8bb0\u5f55\u5bf9\u5e94\u54ea\u4e2a\u8bcd\u6cd5\u5c42\u6b21\uff0c\u5bf9\u4e8e\u5728\u6700\u5916\u5c42\u8bcd\u6cd5\u5c42\u6b21\u51fd\u6570\u7684\u6d3b\u52a8\u8bb0\u5f55\u4e0d\u540c\u4e8e\u5728\u5176\u5b83\u8bcd\u6cd5\u5c42\u6b21\u51fd\u6570\u7684\u6d3b\u52a8\u8bb0\u5f55\uff0c\u8fd9\u4e0d\u662f\u95ee\u9898\u3002<\/p>\n

    \u5448\u73b0\u4e00\u4e2a\u91cd\u8981\u95ee\u9898\u7684\u4e8b\u5b9e\u662f\uff0c\u4e0d\u4ec5\u662f\u4ee3\u7801\u7684\u4e00\u4e2a\u6307\u9488\uff0c\u5728\u4e00\u4e2a\u5185\u90e8\u8bcd\u6cd5\u5c42\u6b21\u7684\u4e00\u4e2a\u51fd\u6570\u7684\u8c03\u7528\u989d\u5916\u8981\u6c42\u6307\u5411\u8bcd\u6cd5\u4e0a\u5c01\u88c5\u51fd\u6570\u7684\u6b63\u786e\u6d3b\u52a8\u8bb0\u5f55\u7684\u4e00\u4e2a\u6307\u9488\u3002<\/p>\n

    \u5982\u679c\u6211\u4eec\u5e0c\u671b\u80fd\u81ea\u7531\u5730\u5411\u5728\u5185\u90e8\u8bcd\u6cd5\u5c42\u6b21\u7684\u51fd\u6570\u4f20\u9012\u6307\u9488\uff0c\u8fd9\u4e2a\u4fe1\u606f\u5fc5\u987b\u4e0e\u6307\u5411\u8be5\u51fd\u6570\u4ee3\u7801\u7684\u6307\u9488\u4e00\u8d77\u4f20\u9012\uff0c\u56e0\u4e3a\u8fd9\u4e2a\u4fe1\u606f\u4e0d\u80fd\u4ee5\u4efb\u4f55\u5176\u5b83\u65b9\u5f0f\u63a8\u5bfc\u3002<\/p>\n

    \u53ea\u8981\u6211\u4eec\u6ca1\u6709\u628a\u51fd\u6570\u7528\u4f5c\u5176\u5b83\u51fd\u6570\u7684\u53c2\u6570\uff0c\u6216\u628a\u51fd\u6570\u8d4b\u7ed9\u53d8\u91cf\uff0c\u7f16\u8bd1\u5668\u53ef\u4ee5\u4e0d\u52a8\u58f0\u8272\u5730\u786e\u4fdd\u5411\u88ab\u8c03\u7528\u8005\u4f20\u9012\u6b63\u786e\u8bcd\u6cd5\u73af\u5883\u7684\u4fe1\u606f\u3002\u4e0d\u8fc7\uff0c\u4e00\u65e6\u6211\u4eec\u5c1d\u8bd5\u628a\u51fd\u6570\u4f20\u9012\u4e3a\u6570\u636e\uff0c\u6211\u4eec\u9047\u5230\u4e00\u4e2a\u95ee\u9898\u3002\u5728C++\u4e2d\uff0c\u5f53\u5b9a\u4e49\u53ca\u4f7f\u7528\u4e00\u4e2a\u51fd\u6570\u6307\u9488\u65f6\uff0c\u4ec5\u9700\u8981\u4e3a\u4e00\u4e2a\u6307\u9488\u4fdd\u7559\u5e76\u4f20\u9012\u8db3\u591f\u7684\u7a7a\u95f4\u3002\u7136\u800c\uff0c\u4e00\u4e2a\u95ed\u5305\uff0c\u5373\u5e26\u6709\u4e00\u4e2a\u73af\u5883\u7684\u51fd\u6570\uff0c\u901a\u5e38\u8981\u6c42\u4e24\u4e2a\u6307\u9488\uff0c\u5c31\u50cf\u6211\u4eec\u521a\u770b\u5230\u7684\u3002<\/p>\n

    \u6539\u53d8\u4e00\u4e2aC++\u51fd\u6570\u6307\u9488\u7684\u8868\u793a\u4e3a\u4e24\u4e2a\u6307\u9488\u5927\u5c0f\uff0c\u800c\u4e0d\u662f\u4e00\u4e2a\u6307\u9488\uff0c\u662f\u4e0d\u53ef\u63a5\u53d7\u7684\u3002\u8fd9\u5c06\u610f\u5473\u7740\uff0c\u4f8b\u5982\uff0c\u4e00\u4e2a\u201c\u51fd\u6570\u6307\u9488\u201d\u4e0d\u80fd\u88ab\u8d4b\u7ed9\u7c7b\u578bvoid*\u7684\u4e00\u4e2a\u53d8\u91cf\uff0c\u800c\u4e0d\u4e22\u5931\u4fe1\u606f\u3002<\/p>\n

    \u4e00\u4e2a\u66ff\u4ee3\u65b9\u6cd5\u53ef\u80fd\u662f\u5f15\u5165\u4e00\u4e2a\u65b0\u6570\u636e\u7c7b\u578b\uff0c\u201c\u95ed\u5305\uff08closure\uff09\u201d\uff0c\u5b83\u5fc5\u987b\u7528\u6765\u8868\u8fbe\u5230\u51fd\u6570\u53ca\u5176\u73af\u5883\u7684\u5f15\u7528\uff0c\u5982\u679c\u8fd9\u4e9b\u51fd\u6570\u4e0d\u662f\u5b9a\u4e49\u5728\u5168\u5c40\u57df\u3002\u4f7f\u7528\u4ece\u51fd\u6570\u6307\u9488\u5230\u95ed\u5305\u7684\u9690\u542b\u7c7b\u578b\u8f6c\u6362\u5c06\u5141\u8bb8\u6211\u4eec\u6df7\u5165\u53ef\u4ee5\u7528\u5728\u95ed\u5305\u4f4d\u7f6e\u7684\u51fd\u6570\u6307\u9488\u3002\u4e0d\u8fc7\uff0c\u95ed\u5305\u4e0d\u80fd\u4f20\u9012\u7ed9\u671f\u671b\u51fd\u6570\u6307\u9488\u7684\u51fd\u6570\u3002\u53e6\u5916\uff0c\u56e0\u4e3a\u672c\u8d28\u4e0a\u76f8\u540c\u6982\u5ff5\u7684\u4e24\u4e2a\u6570\u636e\u7c7b\u578b\uff0c\u8bed\u8a00\u53d8\u5f97\u4e0d\u5fc5\u8981\u5730\u6df7\u4e71\u3002<\/p>\n

    \u663e\u7136\uff0c\u8fd9\u4e9b\u505a\u6cd5\u90fd\u4e0d\u53ef\u63a5\u53d7\u3002\u5e78\u8fd0\u7684\u662f\uff0c\u6709\u4e00\u4e2a\u7b80\u5355\u4e14\u9ad8\u6548\u7684\u89e3\u51b3\u65b9\u6848\u3002\u4e8b\u5b9e\u4e0a\uff0c\u6211\u4eec\u7684\u89e3\u51b3\u65b9\u6848\u5b8c\u5168\u4e0eC++\u3001C\u517c\u5bb9\u3002\u7279\u522b\u662f\uff1a<\/p>\n

      \n
    1. \u6211\u4eec\u7684\u95ed\u5305\u53ef\u4ee5\u7528\u5728\u4e00\u4e2aC\u6216C++\u51fd\u6570\u6307\u9488\u53ef\u4ee5\u4f7f\u7528\u7684\u5730\u65b9\uff0c\u751a\u81f3\u4f7f\u7528\u95ed\u5305\u7684\u4ee3\u7801\u7531\u4e0d\u77e5\u9053\u95ed\u5305\u7684\u4e00\u4e2a\u7f16\u8bd1\u5668\u7f16\u8bd1\u3002<\/li>\n
    2. \u5728\u5411\u7f16\u8bd1\u5668\u6dfb\u52a0\u95ed\u5305\u65f6\uff0c\u4e3a\u4e0d\u5305\u542b\u5d4c\u5957\u51fd\u6570\u7684\u51fd\u6570\u4ea7\u751f\u7684\u4ee3\u7801\u4e0d\u6539\u53d8\u3002<\/li>\n<\/ol>\n

      \u4ea7\u751f\u4e00\u4e2a\u95ed\u5305\u7684\u4ee3\u7801\u7247\u6bb5\u901a\u8fc7\u4ea7\u751f\u4e00\u5c0f\u6bb5\u5411\u67d0\u4e2a\u5df2\u77e5\u5bc4\u5b58\u5668\u8f7d\u5165\u9759\u6001\u94fe\uff0c\u5e76\u8df3\u8f6c\u5230\u8be5\u51fd\u6570\uff08\u4e0b\u9762\u5217\u8868\u76840043-0046\u884c\uff09\u7684\u4ee3\u7801\u6765\u5b9e\u73b0\u3002\u5728\u4e00\u4e2a\u51fd\u6570\u7684\u5f00\u5934\uff0c\u8fd9\u4e2a\u5bc4\u5b58\u5668\u7684\u5185\u5bb9\u88ab\u79fb\u5165\u65b0\u6784\u5efa\u7684\u6d3b\u52a8\u8bb0\u5f55\uff080076\u884c\uff09\u9759\u6001\u94fe\u7684\u57df\u3002\u5728\u4e00\u4e2a\u7c7b\u4f3c\u4e8e68000\u6c47\u7f16\u8bed\u8a00[5]\u7684\u6c47\u7f16\u8bed\u8a00\u91cc\uff0c\u8fd9\u5c06\u770b\u8d77\u6765\u50cf\u8fd9\u6837\uff1a<\/p>\n

      0000 ;;; source code:<\/p>\n

      0001 ;;;<\/p>\n

      0002 ;;; function1() {
      \n <\/p>\n

      0003 ;;;      function2() {
      \n <\/p>\n

      0004 ;;;             ...<\/p>\n

      0005 ;;;      }<\/p>\n

      0006 ;;;      void (*x)();<\/p>\n

      0007 ;;;      x=function2;<\/p>\n

      0008 ;;;      ...<\/p>\n

      0009 ;;; }<\/p>\n

      0010<\/p>\n

      0011 ;;; machineregisters:<\/p>\n

      0012 ;;; FP: currentframe<\/p>\n

      0013 ;;; SL: a registerthat is used to hold the static link pointer<\/p>\n

      0014 ;;;        temporarily<\/p>\n

      0015<\/p>\n

      0016 ;;; instruction toload the SL register with constant<\/p>\n

      0017 INST_LOADSL equ0x<\/p>\n

      0018<\/p>\n

      0019 ;;; instruction fordirect jump<\/p>\n

      0020 INST_JUMP equ0x<\/p>\n

      0021<\/p>\n

      0022 function1:<\/p>\n

      0023         ;;; allocate space for the followingvariables:<\/p>\n

      0024         ;;; void* $dl -- dynamic link chain<\/p>\n

      0025         ;;; void* $sl -- static link chain<\/p>\n

      0026         ;;; int $stub[4] -- space for machine code forclosure<\/p>\n

      0027         ;;; int (*x)() -- a function pointer<\/p>\n

      0028         ;;; also sets up the dynamic link chain<\/p>\n

      0029<\/p>\n

      0030 $dl equ -4<\/p>\n

      0031 $sl equ -8<\/p>\n

      0032 $stub equ -24<\/p>\n

      0033 function1.x equ -28<\/p>\n

      0034<\/p>\n

      0035         link FP,28<\/p>\n

      0036<\/p>\n

      0037          ;;; set up the static link chain<\/p>\n

      0038<\/p>\n

      0039          move SL,$sl(FP)<\/p>\n

      0040<\/p>\n

      0041          ;;; create closure for function2<\/p>\n

      0042<\/p>\n

      0043          move #INST_LOADSL,$stub(FP)<\/p>\n

      0044          move FP,$stub+4(FP)<\/p>\n

      0045          move #INST_JUMP,$stub+8(FP)<\/p>\n

      0046          moveea function2,$stub+12(FP)<\/p>\n

      0047<\/p>\n

      0048          ;;; x=function2<\/p>\n

      0049<\/p>\n

      0050          moveea stub(FP),function1.x(FP)<\/p>\n

      0051          ...<\/p>\n

      0052<\/p>\n

      0053          ;;; code using x<\/p>\n

      0054<\/p>\n

      0055          move function1.x(FP),R1<\/p>\n

      0056          call(R1)<\/p>\n

      0057          ...<\/p>\n

      0058<\/p>\n

      0059          ;;;finish up<\/p>\n

      0060<\/p>\n

      0061          unlinkFP<\/p>\n

      0062          return<\/p>\n

      0063<\/p>\n

      0064 function2:<\/p>\n

      0065          ;;;function entry, as above<\/p>\n

      0066<\/p>\n

      0067          link4<\/p>\n

      0068<\/p>\n

      0069 $dl equ -4<\/p>\n

      0070 $sl equ -8<\/p>\n

      0071<\/p>\n

      0072          ;;; set up the static link chain<\/p>\n

      0073          ;;; register SL was set up by the stub<\/p>\n

      0074          ;;; code in function1<\/p>\n

      0075<\/p>\n

      0076          moveSL,$sl<\/p>\n

      0077          ...<\/p>\n

      0078<\/p>\n

      0079          unlinkFP<\/p>\n

      0080          return<\/p>\n

      \u4ee3\u7801\u6570\u7ec4$stub\u7684\u751f\u547d\u671f\u4e0efunction1\u6d3b\u52a8\u8bb0\u5f55\u7684\u751f\u547d\u671f\u76f8\u540c\u3002\u8fd9\u662f\u5408\u7406\u7684\uff0c\u56e0\u4e3a\u8fd9\u4e2a\u7531$stub\u9690\u542b\u5b9a\u4e49\u7684\u9759\u6001\u94fe\uff0c\u4e00\u65e6function1\u9000\u51fa\u5c31\u6210\u4e3a\u65e0\u6548\u7684[6]\u3002<\/p>\n

      \u8fd9\u662f\u57fa\u672c\u7684\u60f3\u6cd5\u3002\u6709\u51e0\u4e2a\u7f16\u8bd1\u65f6\u4f18\u5316\u7684\u53ef\u80fd\uff0c\u5176\u4e2d\u4e00\u4e9b\u6211\u4eec\u5df2\u7ecf\u63d0\u5230\u3002\u5982\u679cfunction1\u662f\u5b9a\u4e49\u5728\u5168\u5c40\u57df\u7684\uff0c \u4f8b\u5982\uff0c\u5b83\u4e0d\u9700\u8981\u4e3a\u5176\u6d3b\u52a8\u8bb0\u5f55\u4e2d\u7684\u9759\u6001\u94fe\u4fdd\u7559\u7a7a\u95f4\u3002\u5982\u679cfunction2\u6ca1\u6709\u5f15\u7528\u4efb\u4f55\u5728function1\u6d3b\u52a8\u8bb0\u5f55\u4e2d\u7684\u53d8\u91cf\uff0c\u7f16\u8bd1\u5668\u53ef\u4ee5\u628afunction1\u7684\u6d3b\u52a8\u8bb0\u5f55\u7559\u5728\u4f20function2\u7684\u9759\u6001\u94fe\u4e4b\u5916\u3002<\/p>\n

      \u5982\u679cfunction2\u6ca1\u6709\u5f15\u7528\u4efb\u4f55\u975e\u5c40\u90e8\uff0c\u975e\u5168\u5c40\u53d8\u91cf\uff0c\u5176\u5b9a\u4e49\u5b9e\u9645\u4e0a\u53ef\u4ee5\u79fb\u5230\u5168\u5c40\u57df\uff08\u9664\u4e86\u5176\u540d\u5b57\u7684\u4f5c\u7528\u57df\uff09\uff0c\u5e76\u4e14\u5728function1\u5185\u4e0d\u9700\u8981\u4ea7\u751f\u4e00\u4e2a\u9759\u6001\u94fe\u57df\uff0c\u4e5f\u4e0d\u9700\u8981\u4ea7\u751f\u4e00\u4e2a\u4ee3\u7801\u5b58\u6839\u3002\u5982\u679cfunction2\u4ec5\u5728function1\u5185\u4f7f\u7528\uff0c\u5e76\u4e14\u6ca1\u6709\u95ed\u5305\u4f20\u9012\uff0c\u4ea7\u751f\u5b58\u6839\u4ee3\u7801\u7684\u4ee3\u7801\u53ef\u4ee5\u6d88\u9664\uff0c\u56e0\u4e3a\u7f16\u8bd1\u5668\u53ef\u4ee5\u4ea7\u751f\u5728\u8c03\u7528function2\u4e4b\u524d\u5185\u8054\u8f7d\u5165SL\u7684\u4ee3\u7801[7]\u3002<\/p>\n

      3 \u5b83\u7684\u6548\u7387\u5982\u4f55\uff1f<\/h2>\n

      \u4e3a\u4e86\u4e86\u89e3\u8fd9\u4e2a\u65b9\u6848\u7684\u6548\u7387\u5982\u4f55\uff0c\u6211\u4eec\u5fc5\u987b\u628a\u5b83\u4e0e\u66ff\u4ee3\u5b9e\u73b0\u6bd4\u8f83\u3002\u4e24\u4e2a\u6700\u76f4\u63a5\u7684\u5b9e\u73b0\u662f\u628a\u4e00\u4e2a\u95ed\u5305\u8868\u793a\u4e3a\u5e26\u6709\u4e24\u4e2a\u6210\u5458\u7684\u7ed3\u6784\u4f53\uff0c\u4e00\u4e2a\u4ee3\u7801\u6307\u9488\u53ca\u4e00\u4e2a\u73af\u5883\u6307\u9488\uff0c\u6216\u8868\u793a\u4e3a\u8fd9\u6837\u4e00\u4e2a\u7ed3\u6784\u4f53\u7684\u6307\u9488\u3002<\/p>\n

      \u7531\u6211\u4eec\u65b9\u6848\u8981\u6c42\u7684\u989d\u5916\u7a7a\u95f4\u4ec5\u5305\u62ec\u4e24\u6761\u5305\u542b\u5728\u5b58\u6839\u4ee3\u7801\u4e2d\u673a\u5668\u6307\u4ee4\uff0c\u5728function1\u4e2d\u7684\u4e24\u6761\u6307\u4ee4\u7528\u4e8e\u4ea7\u751f\u5728\u5b58\u6839\u4ee3\u7801\u4e2d\u7684\u4e24\u6761\u673a\u5668\u6307\u4ee4\u3002\u5206\u914d\u53ca\u4f20\u9012\u95ed\u5305\u4e0e\u6211\u4eec\u4f7f\u7528\u4e00\u4e2a\u7ed3\u6784\u4f53\u7684\u4e00\u4e2a\u6307\u9488\u90a3\u6837\u9ad8\u6548\u3002<\/p>\n

      \u4e0d\u8fc7\uff0c\u521b\u5efa\u95ed\u5305\u7684\u5f00\u9500\u76f8\u5bf9\u4e0d\u91cd\u8981\u3002\u6b63\u5982\u6211\u4eec\u5728\u4e0a\u9762\u770b\u5230\u7684\uff0c\u4ec5\u5f53\u8981\u4f20\u9012\u4e00\u4e2a\u51fd\u6570\u6307\u9488\u65f6\uff0c\u7f16\u8bd1\u5668\u624d\u9700\u8981\u521b\u5efa\u4e00\u4e2a\u95ed\u5305\u3002\u5728\u6211\u4eec\u7684\u7ecf\u9a8c\u91cc\uff0c\u4e00\u4e2a\u88ab\u4f20\u9012\u7684\u51fd\u6570\u6307\u9488\u901a\u5e38\u662f\u8981\u53cd\u590d\u4f7f\u7528\u7684\uff0c\u56e0\u6b64\u8c03\u7528\u4e00\u4e2a\u95ed\u5305\u7684\u5f00\u9500\u8fdc\u6bd4\u521b\u5efa\u5b83\u7684\u5f00\u9500\u91cd\u8981\u3002<\/p>\n

      \u8ba9\u6211\u4eec\u770b\u4e00\u4e0b\u5728\u8fd9\u4e09\u4e2a\u95ed\u5305\u4e0d\u540c\u5b9e\u73b0\u4e2d\u6267\u884c\u7684\u6307\u4ee4\u5e8f\u5217\u3002\u9996\u5148\uff0c\u662f\u76f4\u63a5\u8868\u793a\u4e3a\u7ed3\u6784\u4f53\u7684\u95ed\u5305\u7684\u6307\u4ee4\u5e8f\u5217[8]\u3002\u8fd9\u4e2a\u95ed\u5305\u5728\u5f53\u524d\u6d3b\u52a8\u8bb0\u5f55\u504f\u79fbx\u5904\u5305\u542b\u4e24\u4e2a\u673a\u5668\u5b57\uff08\u6307\u9488\uff09[9]\uff1a<\/p>\n

      move x(FR),SL<\/p>\n

      move x+4(FR),R1<\/p>\n

      call (R1)<\/p>\n

      \u5728\u6307\u5411\u4e00\u4e2a\u95ed\u5305\u7684\u6307\u9488\u7684\u60c5\u5f62\u91cc\uff0c\u8c03\u7528\u5e8f\u5217\u53d8\u5f97\u6709\u4e9b\u590d\u6742\u3002\u5047\u5b9apx\u662f\u5728\u5f53\u524d\u6d3b\u52a8\u8bb0\u5f55\u4e2d\u6307\u5411\u8fd9\u4e2a\u95ed\u5305\u7684\u6307\u9488\u7684\u504f\u79fb[10]\uff1a<\/p>\n

      move px(FR),R1<\/p>\n

      move (R1),SL<\/p>\n

      move 4(R1),R1<\/p>\n

      call (R1)<\/p>\n

      \u5bf9\u4e8e\u6211\u4eec\u7684\u5efa\u8bae\uff0c\u9047\u5230\u7684\u6307\u4ee4\u5e8f\u5217\u662f\uff1a<\/p>\n

      move px(FR),R1<\/p>\n

      call (R1)<\/p>\n

      move #staticLink,SL<\/p>\n

      jmp function<\/p>\n

      \u6211\u4eec\u770b\u5230\uff0c\u5f53\u6307\u5411\u4e00\u4e2a\u8981\u6c42\u9759\u6001\u94fe\u6307\u9488\u7684\u51fd\u6570\u7684\u51fd\u6570\u6307\u9488\u88ab\u8c03\u7528\u65f6\uff0c\u6267\u884c\u7684\u6307\u4ee4\u5e8f\u5217\u6ca1\u6709\u592a\u5927\u7684\u5dee\u5f02\u3002\u5728\u6548\u7387\u65b9\u9762\u4e3b\u8981\u7684\u5dee\u522b\u5c06\u53ef\u80fd\u6765\u81ea\u7f13\u5b58\u4e0e\u6307\u4ee4\u9884\u53d6\u7684\u6548\u679c\u3002\u67d0\u4e9b\u7b80\u5355\u7684\u5b9e\u9a8c\u8868\u660e\u572880386\u4e0a\u4e00\u4e2a\u4f20\u9012\u4e00\u4e2a\u9759\u6001\u94fe\u6307\u9488\u7684call\/return\u5bf9\u9700\u8981\u5927\u7ea6\u4e00\u4e2a\u7b80\u5355\u7684\u95f4\u63a5\u6216\u76f4\u63a5\u51fd\u6570\u8c03\u7528\u65f6\u95f4\u76841.5\u500d\u3002\u5982\u679c\u4f7f\u7528\u6211\u4eec\u63d0\u8bae\u7684\u6307\u4ee4\u5e8f\u5217\uff0c\u8fd9\u4e2a\u6570\u5b57\u589e\u52a0\u5230\u5927\u7ea61.8\u500d\u3002<\/p>\n

      4 \u53ef\u79fb\u690d\u6027\u95ee\u9898<\/h2>\n

      \u4e3a\u4e86\u5b9e\u73b0\u6211\u4eec\u7684\u63d0\u8bae\uff0c\u4e00\u6bb5\u4ee3\u7801\u80fd\u591f\u5728\u8fd0\u884c\u65f6\u4ea7\u751f\u4e00\u5c0f\u6bb5\u4ee3\u7801\u5e76\u6267\u884c\u5b83\u662f\u5fc5\u987b\u7684\uff1b\u4e0d\u8fc7\uff0c\u4ea7\u751f\u7684\u4ee3\u7801\u4e0d\u9700\u8981\u5fc5\u987b\u653e\u5728\u6808\u4e0a\u3002<\/p>\n

      \u5728\u5927\u591a\u6570\u73b0\u4ee3\u8ba1\u7b97\u673a\u67b6\u6784\u4e0a\uff0c\u50cf68000\u7cfb\u5217\u5fae\u5904\u7406\u5668\u3010Mot80\u3011\uff0cVAX\u3010Dig81b\u3011\u53ca80386\u3010int87\u3011\uff0c\u8fd9\u662f\u53ef\u80fd\u4e14\u7b80\u5355\u7684\u3002\u5373\u4f7f\u5728\u5e26\u6709\u5355\u72ec\u6307\u4ee4\u3001\u6570\u636e\u7a7a\u95f4\uff08I\u4e0eD\u7a7a\u95f4\uff09\u7684PDP-11\u7cfb\u5217\u5904\u7406\u5668\u4e0a\uff0c\u6808\u901a\u5e38\u540c\u65f6\u6620\u5c04\u5230I\u3001D\u7a7a\u95f4\u5141\u8bb8\u6808\u4e0a\u6307\u4ee4\u7684\u6267\u884c\uff08\u5728\u6807\u51c6PDP-11\u6307\u4ee4\u8c03\u7528\u5e8f\u5217\u4e2d\uff0cMARK\u6307\u4ee4\u5728\u6808\u5916\u6267\u884c\uff0c\u53c2\u8003PDP-11\u5904\u7406\u5668\u624b\u518c\u3010Dig81a\u3011\uff09\u3002<\/p>\n

      \u4e0d\u8fc7\uff0c\u6709\u67d0\u4e9b\u67b6\u6784\u4e0e\/\u6216\u64cd\u4f5c\u7cfb\u7edf\u7981\u6b62\u7a0b\u5e8f\u5728\u8fd0\u884c\u65f6\u4ea7\u751f\u5e76\u6267\u884c\u4ee3\u7801\u3002\u6211\u4eec\u8ba4\u4e3a\u8fd9\u4e2a\u9650\u5236\u662f\u6b66\u65ad\u7684[11]\uff0c\u5e76\u89c6\u5b83\u4e3a\u7cdf\u7cd5\u7684\u786c\u4ef6\u6216\u8f6f\u4ef6\u8bbe\u8ba1\u3002\u7f16\u7a0b\u8bed\u8a00\uff0c\u50cfFORTH\uff0cLisp\u6216Smalltalk\u7684\u5b9e\u73b0\uff0c\u53ef\u4ee5\u4ece\u5728\u8fd0\u884c\u65f6\u5feb\u901f\u4ea7\u751f\u6216\u4fee\u6539\u4ee3\u7801\u5f97\u5230\u5f88\u5927\u7684\u597d\u5904\u3002<\/p>\n

      \u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u53e6\u4e00\u4e2a\u6280\u5de7\uff0c\u751a\u81f3\u5728\u8fd9\u4e9b\u67b6\u6784\u4e0a\uff0c\u5b9e\u73b0\u8bcd\u6cd5\u95ed\u5305\u3002\u6211\u4eec\u5728\u6307\u4ee4\u7a7a\u95f4\u9884\u5206\u914d\u8fd9\u4e2a\u5f62\u5f0f\u7684\u6307\u4ee4\u5e8f\u5217\u6570\u7ec4\uff1a<\/p>\n

      stub_n movelocation_n,R1<\/p>\n

                  move (R1),SL<\/p>\n

                  move location_n+4,R1<\/p>\n

                  jmp (R1)<\/p>\n

      \u6211\u4eec\u628a\u8fd9\u4e2a\u6570\u7ec4\u7528\u4f5c\u5206\u914d\u53ca\u56de\u6536\u95ed\u5305\u5b58\u6839\u7684\u4e00\u4e2a\u6808\u3002\u5728\u6570\u636e\u7a7a\u95f4\u7684\u4e00\u4e2a\u5bf9\u5e94\u6570\u7ec4\u4fdd\u5b58\u6307\u5411\u4ee3\u7801\u53ca\u8fd9\u4e2a\u95ed\u5305\u9759\u6001\u94fe\u7684\u5b9e\u9645\u6307\u9488\u3002\u8fd9\u4e24\u4e2a\u65b0\u6808\u7684\u884c\u4e3a\u672c\u8d28\u4e0a\u4e0e\u8fd0\u884c\u65f6\u6808\u4e00\u6837\u3002\u7279\u522b\u7684\uff0c\u5fc5\u987b\u4fee\u6539longjmp\u6765\u6b63\u786e\u5730\u6062\u590d\u5b58\u6839\u6808\u53ca\u4f4d\u7f6e\u6808\u7684\u4e24\u4e2a\u6808\u6307\u9488\u3002<\/p>\n

      5 \u5c06\u6765\u7684\u6269\u5c55<\/h2>\n

      \u6211\u4eec\u89c2\u5bdf\u5230\u5728\u4e0a\u9762\u7684\u4e00\u4e9b\u4f8b\u5b50\u4e2d\uff0c\u901a\u5e38\u4e0d\u9700\u8981\u663e\u5f0f\u5730\u547d\u540d\u4e00\u4e2a\u51fd\u6570\u3002\u5f53\u6211\u4eec\u4f7f\u7528\u63a5\u53d7\u51fd\u6570\u6307\u9488\u4f5c\u4e3a\u53c2\u6570\u7684\u8fed\u4ee3\u5668\u65f6\uff0c\u66f4\u662f\u5982\u6b64\u3002\u4e0a\u9762\u7ed9\u51fa\u7684Lisp\u4e0eSmalltalk\u4ee3\u7801\u7684\u4f8b\u5b50\u8bbe\u8ba1\u754c\u672a\u547d\u540d\u51fd\u6570\u3002\u6211\u4eec\u5efa\u8bae\u628a\u4e00\u4e2a\u672a\u547d\u540d\u51fd\u6570\u8868\u8fbe\u4e3a\u4e00\u4e2a\u590d\u5408\u8bed\u53e5\u5230\u4e00\u4e2a\u51fd\u6570\u6307\u9488\u7684\u8f6c\u6362\u3002\u4f8b\u5982\uff0c\u4e0b\u9762\u8868\u8fbe\u5f0f\u7684\u503c\u662f\u4e00\u4e2a\u51fd\u6570\u6307\u9488\u6216\u4e00\u4e2a\u95ed\u5305\uff08\u4f9d\u8d56\u4e8e\u4e0a\u4e0b\u6587\uff09\uff1a<\/p>\n

      (int (*)(int x)){ returnx+1; }<\/p>\n

      \u6216\u8005\uff0c\u6211\u4eec\u53ef\u4ee5\u5f15\u5165\u4e00\u4e2a\u65b0\u5173\u952e\u5b57\uff0cunnamed\uff0c\u5e76\u628a\u76f8\u540c\u7684\u6784\u9020\u5199\u4f5c\uff1a<\/p>\n

      (int unnamed(int x){return x+1; })<\/p>\n

      \u6211\u4eec\u7a0d\u5fae\u5730\u66f4\u559c\u6b22\u7b2c\u4e00\u4e2a\u5f62\u5f0f\uff0c\u4f46\u7b2c\u4e8c\u4e2a\u5f62\u5f0f\u53ef\u80fd\u66f4\u5bb9\u6613\u89e3\u6790\uff0c\u5e76\u4e14\u5141\u8bb8\u66f4\u597d\u7684\u8bed\u6cd5\u9519\u8bef\u68c0\u67e5\u4e0e\u6062\u590d\u3002<\/p>\n

      \u6211\u4eec\u63d0\u8bae\u5b9e\u73b0\u95ed\u5305\u7684\u65b9\u5f0f\u9650\u5236\u5b83\u4eec\u7684\u751f\u547d\u671f\u4e3a\u5b83\u4eec\u6240\u5728\u6d3b\u52a8\u8bb0\u5f55\u7684\u751f\u547d\u671f\u3002\u4e3a\u4e86\u4f7f\u5f97\u95ed\u5305\u6210\u4e3a\u4e0eC++\u4e2d\u5176\u5b83\u6570\u636e\u7c7b\u578b\u76f8\u540c\u7ea7\u522b\u7684\u4e00\u4e2a\u6570\u636e\u7c7b\u578b\uff0c\u5e94\u8be5\u53ef\u80fd\u5206\u914d\u53ca\u56de\u6536\u95ed\u5305\u3002\u63d0\u4f9b\u53ef\u4ee5\u5904\u7406\u4f5c\u6570\u636e\u7ed3\u6784\u7684\u95ed\u5305\u6709\u5f88\u597d\u7684\u7406\u7531\u3002Abelson\u4e0eSussman\u3010AS85\u3011\u5f3a\u70c8\u652f\u6301\u8fd9\u4e2a\u7279\u6027\uff0c\u800c\u5728Scheme\u7f16\u7a0b\u8bed\u8a00\u3010RC86\u3011\u4e2d\uff0c\u5b83\u4eec\u901a\u5e38\u7528\u4e8e\u6784\u5efa\u590d\u6742\u7684\u6570\u636e\u7c7b\u578b\u3002\u4e0d\u8fc7\uff0c\u7c7b\u4e0e\u7ed3\u6784\u4f53\u63d0\u4f9b\u4e86\u5806\u5206\u914d\u95ed\u5305\u7684\u5927\u90e8\u5206\u529f\u80fd\u3002<\/p>\n

      6 \u7ed3\u8bed<\/h2>\n

      \u5d4c\u5957\u51fd\u6570\u7684\u5b9a\u4e49\u4ee5\u53ca\u521b\u5efa\u5e26\u6709\u6700\u5c11\u52a8\u6001\u751f\u547d\u671f\u7684\u80fd\u529b\uff0c\u662f\u8bb8\u591a\u73b0\u4ee3\u7f16\u7a0b\u5f62\u5f0f\u7684\u91cd\u8981\u90e8\u5206\u3002\u5927\u591a\u6570\u73b0\u4ee3\u7f16\u7a0b\u8bed\u8a00\u63d0\u4f9b\u5b83\uff0c\u5e76\u4e14\u5b83\u53ef\u4ee5\u88ab\u52a0\u5165C++\uff08\u53caC\uff09\u7f16\u7a0b\u8bed\u8a00\uff0c\u800c\u4e0d\u4f1a\u5f71\u54cd\u6267\u884c\u7684\u6548\u7387\u6216\u4e0d\u91c7\u7528\u8be5\u7279\u6027\u7a0b\u5e8f\u7684\u542b\u4e49\u3002\u56e0\u6b64\u6211\u4eec\u671f\u671b\u770b\u5230\u5d4c\u5957\u51fd\u6570\u5b9a\u4e49\u53ca\u8bcd\u6cd5\u95ed\u5305\u5c06\u88ab\u52a0\u5165C++\u8bed\u8a00\u7684\u5b9a\u4e49\u3002\u6211\u4eec\u76ee\u524d\u6b63\u5728\u81f4\u529b\u4e8e\u6269\u5c55GNU C\u3010Sta88a\u3011\u3010Sta88b\u3011\u4e0eC++\u3010Tie88\u3011\u7f16\u8bd1\u5668\uff0c\u63d0\u4f9b\u5d4c\u5957\u51fd\u6570\u5b9a\u4e49\u4e0e\u95ed\u5305\u3002\u6709\u4e00\u4e2a\u597d\u7684\u3001\u514d\u8d39\u7684\uff0c\u5e26\u6709\u6e90\u4ee3\u7801\u7ea7\u8c03\u8bd5\u5668\u7684\u7f16\u8bd1\u5668\u53ef\u7528\uff0c\u5c06\u9f13\u52b1\u66f4\u591a\u7684\u4eba\u4f7f\u7528\u8fd9\u4e2a\u7279\u6027\u3002<\/p>\n

      \u81f4\u8c22<\/h2>\n

      \u6211\u8981\u611f\u8c22Richard M. Stallman\uff0cRobert S. Thau\uff0c\u4ee5\u53ca\u8bb8\u591a\u5bf9\u8fd9\u4e2a\u63d0\u8bae\u4e0e\u8bba\u6587\u7ed9\u51fa\u4e86\u6709\u7528\u8bc4\u8bba\u7684\u4eba\u3002<\/p>\n

      \u53c2\u8003\u6587\u732e<\/h2>\n

      [AS85] Harold Abelson and GeraldJay Sussman. Structure and Interpretation of Computer Programs. MITPress, 1985.<\/p>\n

      [AU79] Alfred V. Aho and Je_reyD. Ullman. Principles of Compiler Design. Addison-Wesley, 1979.<\/p>\n

      [Dig81a] Digital EquipmentCorporation. PDP-11 Processor Handbook, 1981.<\/p>\n

      [Dig81b] Digital EquipmentCorporation. VAX Architecture Handbook, 1981.<\/p>\n

      [GR83] Adele Goldberg and DavidRobson. Smalltalk-80: The Language and its Implementation. Addison-Wesley,1983.<\/p>\n

      [Int87] Intel Corporation. 80386Programmer's Reference Manual, 1987.<\/p>\n

      [Mot80] Motorola SemiconductorsProducts, Inc. MC68000 16-bit Microprocessor User's Manual, 1980.<\/p>\n

      [RC86] Jonathan Rees and WilliamClinger. The Revised3 Report on the Algorithmic Language Scheme.Technical Report 848a, MIT Arti_cial Intelligence Laboratory, September 1986.<\/p>\n

      [Sta88a] Richard M. Stallman. Internalsof GNU CC, April 1988.<\/p>\n

      [Sta88b] Richard M. Stallman. The GNUDebugger for GNU C++ Free Software, April 1988.<\/p>\n

      [Ste84] Guy L. Steele Jr. CommonLISP: The Language. DigitalPress, 1984.<\/p>\n

      [Tie88]Michael D. Tiemann. User's Guide to GNU C++, May1988.<\/p>\n

      [Wir77]Niklaus Wirth. Compilerbau. B. G. Teubner, Stuttgart, 1977.<\/p>\n

      [Wir79]Niklaus Wirth. Algorithmen undDatenstrukturen. B. G.Teubner, Stuttgart,1979.<\/p>\n

      \n <\/p>\n
      \n
      \n

      [1] \u4f5c\u8005\u7684\u5730\u5740\uff1a MIT ArtificialIntelligence Laboratory, Room 711, 545 Technology Square, Cambridge,<\/p>\n

      MA 02139, US\u3002 \u4f5c\u8005\u7531\u6765\u81ea\u4ed9\u7ae5\u57fa\u91d1\u4f1a\uff08Fairchild foundation\uff09\u7684\u4e00\u4e2a\u534f\u4f1a\u8d44\u52a9\u3002<\/p>\n<\/p><\/div>\n

      \n

      [2]\u9664\u975esift\u58f0\u660e\u6216\u5b9a\u4e49\u53e6\u4e00\u4e2a\u6807\u8bc6\u7b26v<\/p>\n<\/p><\/div>\n

      \n

      [3] \u6211\u4eec\u5fc5\u987b\u4e3a\u51fd\u6570count\u53d1\u660e\u4e00\u4e2a\u540d\u5b57\uff0c\u8fd9\u4ecd\u7136\u662f\u4ee4\u4eba\u70e6\u607c\u7684\u3002\u5728\u540e\u9762\u7ae0\u8282\u4e2d\uff0c\u6211\u4eec\u5c06\u5efa\u8bae\u5b9a\u4e49\u533f\u540d\u51fd\u6570\u7684\u8bed\u6cd5\u3002\u8fd9\u91cc\u6211\u4eec\u4f7f\u7528\u5177\u540d\u7248\u672c\u4ee5\u907f\u514d\u8fd9\u65f6\u9677\u5165\u8bed\u6cd5\u95ee\u9898\u3002<\/p>\n<\/p><\/div>\n

      \n

      [4]\u4e00\u4e2a\u6536\u96c6\uff08collection\uff09\u7684\u57fa\u7c7b\u662f\u8be5\u6536\u96c6\u5143\u7d20\u7684\u7c7b\u578b\u3002<\/p>\n<\/p><\/div>\n

      \n

      [5] \u5047\u5b9a\u6240\u6709\u7684\u6570\u636e\u4e0e\u6307\u4ee4\u90fd\u662f32\u4f4d\u5bbd\u3002\u4e34\u65f6\u6807\u53f7\u4ee5\u4e00\u4e2a\"$\"\u5f00\u5934\u3002\u6307\u4ee4moveea\u628a\u5b83\u7b2c\u4e00\u4e2a\u64cd\u4f5c\u6570\u7684\u5b9e\u9645\u5730\u5740\u79fb\u5230\u4e00\u4e2a\u4f4d\u7f6e\u3002\u6307\u4ee4link\u586b\u5145\u6d3b\u52a8\u8bb0\u5f55\u7684\"$dl\"\u57df\u3002<\/p>\n<\/p><\/div>\n

      \n

      [6] \u6211\u4eec\u5c06\u5728\u540e\u9762\u8ba8\u8bba\u53ef\u80fd\u7684\u6269\u5c55\uff0c\u628a\u4e00\u4e2a\u7279\u5b9a\u9759\u6001\u94fe\u7684\u751f\u547d\u671f\u6269\u5c55\u8d85\u51fa\u8be5\u7ec4\u4ef6\u6d3b\u52a8\u8bb0\u5f55\u7684\u52a8\u6001\u751f\u547d\u671f\u3002<\/p>\n<\/p><\/div>\n

      \n

      [7] \u5b9e\u9645\u4e0a\uff0c\u4e00\u4e2a\u53d7\u9650\u5f62\u5f0f\u7684\u5d4c\u5957\uff0c\u5176\u4e2d\u6211\u4eec\u4e0d\u5141\u8bb8\u83b7\u53d6\u5b9a\u4e49\u5728\u5185\u90e8\u8bcd\u6cd5\u5c42\u6b21\u51fd\u6570\u7684\u5730\u5740\uff0c\u53ef\u4ee5\u4e0d\u9700\u8981\u6269\u5c55\u7f16\u8bd1\u5668\u4ea7\u751f\u4ee3\u7801\u5b58\u6839\u6765\u5b9e\u73b0\u3002<\/p>\n<\/p><\/div>\n

      \n

      [8] \u8fd9\u4e9b\u4e0d\u662f\u6c47\u7f16\u8bed\u8a00\u7a0b\u5e8f\u7247\u6bb5\uff0c\u800c\u662f\u5728\u8c03\u7528\u4e00\u4e2a\u95ed\u5305\u671f\u95f4\u6267\u884c\u7684\u6c47\u7f16\u8bed\u8a00\u6307\u4ee4\u7684\u75d5\u8ff9\u3002<\/p>\n<\/p><\/div>\n

      \n

      [9]R1\u662f\u67d0\u4e2a\u901a\u7528\u5bc4\u5b58\u5668\u3002<\/p>\n<\/p><\/div>\n

      \n

      [10]\u5728\u4e0b\u9762\u4f8b\u5b50\u4e2d\u4f4d\u7f6e\uff08R1\uff09\u4e0e4\uff08R1\uff09\u7684\u5185\u5bb9\u53ef\u4ee5\u60f3\u89c1\uff0c\u662f\u88ab\u7f13\u5b58\u7684\u3002<\/p>\n<\/p><\/div>\n

      \n

      [11] \u8fd9\u6837\u7684\u7cfb\u7edf\u901a\u5e38\u63d0\u4f9b\u64cd\u4f5c\u7cfb\u7edf\u8c03\u7528\u6765\u79fb\u52a8\u6570\u636e\u5230\u6307\u4ee4\u7a7a\u95f4\uff0c\u4f8b\u5982\uff0c\u4e3a\u4e86\u8f85\u52a9\u8f7d\u5165\u5668\uff1b\u4e0d\u8fc7\uff0c\u4e00\u4e2a\u64cd\u4f5c\u7cfb\u7edf\u8c03\u7528\u7684\u5f00\u9500\u5bf9\u6784\u5efa\u4e00\u4e2a\u95ed\u5305\u800c\u8a00\u592a\u9ad8\u4e86\u3002<\/p>\n<\/p><\/div>\n<\/div>\n

      <\/p>\n","protected":false},"excerpt":{"rendered":"C++\u7684\u8bcd\u6cd5\u95ed\u5305_c++\u57fa\u672c\u8bed\u6cd5C++\u7684\u8bcd\u6cd5\u95ed\u5305ThomasM.Breuel[1]\u7ffb\u8bd1\uff1a\u5434\u6656\u6458\u8981\u6211\u4eec\u63cf\u8ff0C++\u7f16\u7a0b\u8bed\u8a00\u7684\u4e00\u4e2a\u5141\u8bb8\u51fd\u6570\u5b9a\u4e49\u5d4c\u5957\uff0c\u5e76\u63d0...","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"_links":{"self":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/5697"}],"collection":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/comments?post=5697"}],"version-history":[{"count":0,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/5697\/revisions"}],"wp:attachment":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/media?parent=5697"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/categories?post=5697"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/tags?post=5697"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}