{"id":29,"date":"2009-07-12T14:34:00","date_gmt":"2009-07-12T06:34:00","guid":{"rendered":"http:\/\/gsakd878.wordpress.com\/2009\/07\/12\/%e9%ab%98%e8%b4%a8%e9%87%8fc%e6%95%99%e7%a8%8b-%e7%ac%ac3%e7%ab%a0-%e5%91%bd%e5%90%8d%e8%a7%84%e5%88%99"},"modified":"2009-07-12T14:34:00","modified_gmt":"2009-07-12T06:34:00","slug":"%e9%ab%98%e8%b4%a8%e9%87%8fc%e6%95%99%e7%a8%8b-%e7%ac%ac3%e7%ab%a0-%e5%91%bd%e5%90%8d%e8%a7%84%e5%88%99","status":"publish","type":"post","link":"https:\/\/www.keyboardmeow.com\/?p=29","title":{"rendered":"\u9ad8\u8d28\u91cfC++\u6559\u7a0b &#8212; \u7b2c3\u7ae0 \u547d\u540d\u89c4\u5219"},"content":{"rendered":"<div style=\"margin-top:15px;margin-bottom:15px;\">\n<div style=\"margin-top:15px;margin-bottom:15px;\"><span><span>\u9ad8\u8d28\u91cfC++\u6559\u7a0b -- \u7b2c3\u7ae0<br \/>\n\u547d\u540d\u89c4\u5219<\/span><\/span><\/div>\n<div style=\"line-height:20px;background-color:#dddddd;height:20px;color:#666666;\">\n\u6765\u6e90:<a href=\"http:\/\/www.vcworld.net\/\" target=\"_blank\" rel=\"noopener\"><font color=\"#0033FF\">www.vcworld.net<\/font><\/a>\u3000<\/div>\n<div style=\"text-align:left;margin-top:20px;width:95%;margin-bottom:25px;\">\n<p><span>\u6bd4\u8f83\u8457\u540d\u7684\u547d\u540d\u89c4\u5219\u5f53\u63a8Microsoft\u516c\u53f8\u7684\u201c\u5308\u7259\u5229\u201d\u6cd5\uff0c\u8be5\u547d\u540d\u89c4\u5219\u7684\u4e3b\u8981\u601d\u60f3\u662f\u201c\u5728\u53d8\u91cf\u548c\u51fd\u6570\u540d\u4e2d\u52a0\u5165\u524d\u7f00\u4ee5\u589e\u8fdb\u4eba\u4eec\u5bf9\u7a0b\u5e8f\u7684\u7406\u89e3\u201d\u3002\u4f8b\u5982\u6240\u6709\u7684\u5b57\u7b26\u53d8\u91cf\u5747\u4ee5ch\u4e3a\u524d\u7f00\uff0c\u82e5\u662f\u6307\u9488\u53d8\u91cf\u5219\u8ffd\u52a0\u524d\u7f00p\u3002\u5982\u679c\u4e00\u4e2a\u53d8\u91cf\u7531ppch\u5f00\u5934\uff0c\u5219\u8868\u660e\u5b83\u662f\u6307\u5411\u5b57\u7b26\u6307\u9488\u7684\u6307\u9488\u3002<\/span><\/p>\n<p>\u201c\u5308\u7259\u5229\u201d\u6cd5\u6700\u5927\u7684\u7f3a\u70b9\u662f\u70e6\u7410\uff0c\u4f8b\u5982<\/p>\n<p>int i, j, k;<\/p>\n<p>float x, y, z;<\/p>\n<p>\u5018\u82e5\u91c7\u7528\u201c\u5308\u7259\u5229\u201d\u547d\u540d\u89c4\u5219\uff0c\u5219\u5e94\u5f53\u5199\u6210<\/p>\n<p>int iI, iJ, ik; \/\/ \u524d\u7f00 i\u8868\u793aint\u7c7b\u578b<\/p>\n<p>float fX, fY, fZ; \/\/ \u524d\u7f00 f\u8868\u793afloat\u7c7b\u578b<\/p>\n<p>\u5982\u6b64\u70e6\u7410\u7684\u7a0b\u5e8f\u4f1a\u8ba9\u7edd\u5927\u591a\u6570\u7a0b\u5e8f\u5458\u65e0\u6cd5\u5fcd\u53d7\u3002<\/p>\n<p>\n\u636e\u8003\u5bdf\uff0c\u6ca1\u6709\u4e00\u79cd\u547d\u540d\u89c4\u5219\u53ef\u4ee5\u8ba9\u6240\u6709\u7684\u7a0b\u5e8f\u5458\u8d5e\u540c\uff0c\u7a0b\u5e8f\u8bbe\u8ba1\u6559\u79d1\u4e66\u4e00\u822c\u90fd\u4e0d\u6307\u5b9a\u547d\u540d\u89c4\u5219\u3002\u547d\u540d\u89c4\u5219\u5bf9\u8f6f\u4ef6\u4ea7\u54c1\u800c\u8a00\u5e76\u4e0d\u662f\u201c\u6210\u8d25\u60a0\u5173\u201d\u7684\u4e8b\uff0c\u6211\u4eec\u4e0d\u8981\u5316\u592a\u591a\u7cbe\u529b\u8bd5\u56fe\u53d1\u660e\u4e16\u754c\u4e0a\u6700\u597d\u7684\u547d\u540d\u89c4\u5219\uff0c\u800c\u5e94\u5f53\u5236\u5b9a\u4e00\u79cd\u4ee4\u5927\u591a\u6570\u9879\u76ee\u6210\u5458\u6ee1\u610f\u7684\u547d\u540d\u89c4\u5219\uff0c\u5e76\u5728\u9879\u76ee\u4e2d\u8d2f\u5f7b\u5b9e\u65bd\u3002<\/p>\n<p>\u00a0<\/p>\n<p><strong><font size=\"4\">3.1 \u5171\u6027\u89c4\u5219<\/font><\/strong><\/p>\n<p>\u672c\u8282\u8bba\u8ff0\u7684\u5171\u6027\u89c4\u5219\u662f\u88ab\u5927\u591a\u6570\u7a0b\u5e8f\u5458\u91c7\u7eb3\u7684\uff0c\u6211\u4eec\u5e94\u5f53\u5728\u9075\u5faa\u8fd9\u4e9b\u5171\u6027\u89c4\u5219\u7684\u524d\u63d0\u4e0b\uff0c\u518d\u6269\u5145\u7279\u5b9a\u7684\u89c4\u5219\uff0c\u59823.2\u8282\u3002<\/p>\n<p>\u00a0<\/p>\n<p>\u25cf\u3010\u89c4\u52193-1-1\u3011\u6807\u8bc6\u7b26\u5e94\u5f53\u76f4\u89c2\u4e14\u53ef\u4ee5\u62fc\u8bfb\uff0c\u53ef\u671b\u6587\u77e5\u610f\uff0c\u4e0d\u5fc5\u8fdb\u884c\u201c\u89e3\u7801\u201d\u3002<\/p>\n<p>\n\u6807\u8bc6\u7b26\u6700\u597d\u91c7\u7528\u82f1\u6587\u5355\u8bcd\u6216\u5176\u7ec4\u5408\uff0c\u4fbf\u4e8e\u8bb0\u5fc6\u548c\u9605\u8bfb\u3002\u5207\u5fcc\u4f7f\u7528\u6c49\u8bed\u62fc\u97f3\u6765\u547d\u540d\u3002\u7a0b\u5e8f\u4e2d\u7684\u82f1\u6587\u5355\u8bcd\u4e00\u822c\u4e0d\u4f1a\u592a\u590d\u6742\uff0c\u7528\u8bcd\u5e94\u5f53\u51c6\u786e\u3002\u4f8b\u5982\u4e0d\u8981\u628aCurrentValue\u5199\u6210NowValue\u3002<\/p>\n<p>\u00a0<\/p>\n<p>\u25cf\u3010\u89c4\u52193-1-2\u3011\u6807\u8bc6\u7b26\u7684\u957f\u5ea6\u5e94\u5f53\u7b26\u5408\u201cmin-length<br \/>\n&amp;&amp; max-information\u201d\u539f\u5219\u3002<\/p>\n<p>\u51e0\u5341\u5e74\u524d\u8001ANSI<br \/>\nC\u89c4\u5b9a\u540d\u5b57\u4e0d\u51c6\u8d85\u8fc76\u4e2a\u5b57\u7b26\uff0c\u73b0\u4eca\u7684C++\/C\u4e0d\u518d\u6709\u6b64\u9650\u5236\u3002\u4e00\u822c\u6765\u8bf4\uff0c\u957f\u540d\u5b57\u80fd\u66f4\u597d\u5730\u8868\u8fbe\u542b\u4e49\uff0c\u6240\u4ee5\u51fd\u6570\u540d\u3001\u53d8\u91cf\u540d\u3001\u7c7b\u540d\u957f\u8fbe\u5341\u51e0\u4e2a\u5b57\u7b26\u4e0d\u8db3\u4e3a\u602a\u3002\u90a3\u4e48\u540d\u5b57\u662f\u5426\u8d8a\u957f\u7ea6\u597d\uff1f\u4e0d\u89c1\u5f97!<br \/>\n\u4f8b\u5982\u53d8\u91cf\u540dmaxval\u5c31\u6bd4maxValueUntilOverflow\u597d\u7528\u3002\u5355\u5b57\u7b26\u7684\u540d\u5b57\u4e5f\u662f\u6709\u7528\u7684\uff0c\u5e38\u89c1\u7684\u5982i,j,k,m,n,x,y,z\u7b49\uff0c\u5b83\u4eec\u901a\u5e38\u53ef\u7528\u4f5c\u51fd\u6570\u5185\u7684\u5c40\u90e8\u53d8\u91cf\u3002<\/p>\n<p>\u00a0<\/p>\n<p>\u25cf\u3010\u89c4\u52193-1-3\u3011\u547d\u540d\u89c4\u5219\u5c3d\u91cf\u4e0e\u6240\u91c7\u7528\u7684\u64cd\u4f5c\u7cfb\u7edf\u6216\u5f00\u53d1\u5de5\u5177\u7684\u98ce\u683c\u4fdd\u6301\u4e00\u81f4\u3002<\/p>\n<p>\n\u4f8b\u5982Windows\u5e94\u7528\u7a0b\u5e8f\u7684\u6807\u8bc6\u7b26\u901a\u5e38\u91c7\u7528\u201c\u5927\u5c0f\u5199\u201d\u6df7\u6392\u7684\u65b9\u5f0f\uff0c\u5982AddChild\u3002\u800cUnix\u5e94\u7528\u7a0b\u5e8f\u7684\u6807\u8bc6\u7b26\u901a\u5e38\u91c7\u7528\u201c\u5c0f\u5199\u52a0\u4e0b\u5212\u7ebf\u201d\u7684\u65b9\u5f0f\uff0c\u5982add_child\u3002\u522b\u628a\u8fd9\u4e24\u7c7b\u98ce\u683c\u6df7\u5728\u4e00\u8d77\u7528\u3002<\/p>\n<p>\u00a0<\/p>\n<p>\u25cf\u3010\u89c4\u52193-1-4\u3011\u7a0b\u5e8f\u4e2d\u4e0d\u8981\u51fa\u73b0\u4ec5\u9760\u5927\u5c0f\u5199\u533a\u5206\u7684\u76f8\u4f3c\u7684\u6807\u8bc6\u7b26\u3002<\/p>\n<p>\u4f8b\u5982\uff1a<\/p>\n<p>int x, X; \/\/ \u53d8\u91cfx \u4e0e X \u5bb9\u6613\u6df7\u6dc6<\/p>\n<p>void foo(int x); \/\/ \u51fd\u6570foo \u4e0eFOO\u5bb9\u6613\u6df7\u6dc6<\/p>\n<p>void FOO(float x);<\/p>\n<p>\u00a0<\/p>\n<p>\n\u25cf\u3010\u89c4\u52193-1-5\u3011\u7a0b\u5e8f\u4e2d\u4e0d\u8981\u51fa\u73b0\u6807\u8bc6\u7b26\u5b8c\u5168\u76f8\u540c\u7684\u5c40\u90e8\u53d8\u91cf\u548c\u5168\u5c40\u53d8\u91cf\uff0c\u5c3d\u7ba1\u4e24\u8005\u7684\u4f5c\u7528\u57df\u4e0d\u540c\u800c\u4e0d\u4f1a\u53d1\u751f\u8bed\u6cd5\u9519\u8bef\uff0c\u4f46\u4f1a\u4f7f\u4eba\u8bef\u89e3\u3002<\/p>\n<p>\u00a0<\/p>\n<p>\u25cf\u3010\u89c4\u52193-1-6\u3011\u53d8\u91cf\u7684\u540d\u5b57\u5e94\u5f53\u4f7f\u7528\u201c\u540d\u8bcd\u201d\u6216\u8005\u201c\u5f62\u5bb9\u8bcd\uff0b\u540d\u8bcd\u201d\u3002<\/p>\n<p>\u4f8b\u5982\uff1a<\/p>\n<p>float value;<\/p>\n<p>float oldValue;<\/p>\n<p>float newValue;<\/p>\n<p>\u00a0<\/p>\n<p>\n\u25cf\u3010\u89c4\u52193-1-7\u3011\u5168\u5c40\u51fd\u6570\u7684\u540d\u5b57\u5e94\u5f53\u4f7f\u7528\u201c\u52a8\u8bcd\u201d\u6216\u8005\u201c\u52a8\u8bcd\uff0b\u540d\u8bcd\u201d\uff08\u52a8\u5bbe\u8bcd\u7ec4\uff09\u3002\u7c7b\u7684\u6210\u5458\u51fd\u6570\u5e94\u5f53\u53ea\u4f7f\u7528\u201c\u52a8\u8bcd\u201d\uff0c\u88ab\u7701\u7565\u6389\u7684\u540d\u8bcd\u5c31\u662f\u5bf9\u8c61\u672c\u8eab\u3002<\/p>\n<p>\u4f8b\u5982\uff1a<\/p>\n<p>DrawBox(); \/\/ \u5168\u5c40\u51fd\u6570<\/p>\n<p>box-&gt;Draw(); \/\/ \u7c7b\u7684\u6210\u5458\u51fd\u6570<\/p>\n<p>\u00a0<\/p>\n<p>\u25cf\u3010\u89c4\u52193-1-8\u3011\u7528\u6b63\u786e\u7684\u53cd\u4e49\u8bcd\u7ec4\u547d\u540d\u5177\u6709\u4e92\u65a5\u610f\u4e49\u7684\u53d8\u91cf\u6216\u76f8\u53cd\u52a8\u4f5c\u7684\u51fd\u6570\u7b49\u3002<\/p>\n<p>\u4f8b\u5982\uff1a<\/p>\n<p>int minValue;<\/p>\n<p>int maxValue;<\/p>\n<p>\u00a0<\/p>\n<p>int SetValue(\u2026);<\/p>\n<p>int GetValue(\u2026);<\/p>\n<p>\u00a0<\/p>\n<p>\n\u25cf\u3010\u5efa\u8bae3-1-1\u3011\u5c3d\u91cf\u907f\u514d\u540d\u5b57\u4e2d\u51fa\u73b0\u6570\u5b57\u7f16\u53f7\uff0c\u5982Value1,Value2\u7b49\uff0c\u9664\u975e\u903b\u8f91\u4e0a\u7684\u786e\u9700\u8981\u7f16\u53f7\u3002\u8fd9\u662f\u4e3a\u4e86\u9632\u6b62\u7a0b\u5e8f\u5458\u5077\u61d2\uff0c\u4e0d\u80af\u4e3a\u547d\u540d\u52a8\u8111\u7b4b\u800c\u5bfc\u81f4\u4ea7\u751f\u65e0\u610f\u4e49\u7684\u540d\u5b57\uff08\u56e0\u4e3a\u7528\u6570\u5b57\u7f16\u53f7\u6700\u7701\u4e8b\uff09\u3002<\/p>\n<p>\u00a0<\/p>\n<p><strong><font size=\"4\">3.2<br \/>\n\u7b80\u5355\u7684Windows\u5e94\u7528\u7a0b\u5e8f\u547d\u540d\u89c4\u5219<\/font><\/strong><\/p>\n<p>\u4f5c\u8005\u5bf9\u201c\u5308\u7259\u5229\u201d\u547d\u540d\u89c4\u5219\u505a\u4e86\u5408\u7406\u7684\u7b80\u5316\uff0c\u4e0b\u8ff0\u7684\u547d\u540d\u89c4\u5219\u7b80\u5355\u6613\u7528\uff0c\u6bd4\u8f83\u9002\u5408\u4e8eWindows\u5e94\u7528\u8f6f\u4ef6\u7684\u5f00\u53d1\u3002<\/p>\n<p>\u00a0<\/p>\n<p>\u25cf\u3010\u89c4\u52193-2-1\u3011\u7c7b\u540d\u548c\u51fd\u6570\u540d\u7528\u5927\u5199\u5b57\u6bcd\u5f00\u5934\u7684\u5355\u8bcd\u7ec4\u5408\u800c\u6210\u3002<\/p>\n<p>\u4f8b\u5982\uff1a<\/p>\n<p>class Node; \/\/ \u7c7b\u540d<\/p>\n<p>class LeafNode; \/\/ \u7c7b\u540d<\/p>\n<p>void Draw(void); \/\/ \u51fd\u6570\u540d<\/p>\n<p>void SetValue(int value); \/\/ \u51fd\u6570\u540d<\/p>\n<p>\u00a0<\/p>\n<p>\u25cf\u3010\u89c4\u52193-2-2\u3011\u53d8\u91cf\u548c\u53c2\u6570\u7528\u5c0f\u5199\u5b57\u6bcd\u5f00\u5934\u7684\u5355\u8bcd\u7ec4\u5408\u800c\u6210\u3002<\/p>\n<p>\u4f8b\u5982\uff1a<\/p>\n<p>BOOL flag;<\/p>\n<p>int drawMode;<\/p>\n<p>\u00a0<\/p>\n<p>\u25cf\u3010\u89c4\u52193-2-3\u3011\u5e38\u91cf\u5168\u7528\u5927\u5199\u7684\u5b57\u6bcd\uff0c\u7528\u4e0b\u5212\u7ebf\u5206\u5272\u5355\u8bcd\u3002<\/p>\n<p>\u4f8b\u5982\uff1a<\/p>\n<p>const int MAX = 100;<\/p>\n<p>const int MAX_LENGTH = 100;<\/p>\n<p>\u00a0<\/p>\n<p>\u25cf\u3010\u89c4\u52193-2-4\u3011\u9759\u6001\u53d8\u91cf\u52a0\u524d\u7f00s_\uff08\u8868\u793astatic\uff09\u3002<\/p>\n<p>\u4f8b\u5982\uff1a<\/p>\n<p>void Init(\u2026)<\/p>\n<p>{<\/p>\n<p>static int s_initValue; \/\/ \u9759\u6001\u53d8\u91cf<\/p>\n<p>\u2026<\/p>\n<p>}<\/p>\n<p>\u00a0<\/p>\n<p>\u25cf\u3010\u89c4\u52193-2-5\u3011\u5982\u679c\u4e0d\u5f97\u5df2\u9700\u8981\u5168\u5c40\u53d8\u91cf\uff0c\u5219\u4f7f\u5168\u5c40\u53d8\u91cf\u52a0\u524d\u7f00g_\uff08\u8868\u793aglobal\uff09\u3002<\/p>\n<p>\u4f8b\u5982\uff1a<\/p>\n<p>int g_howManyPeople; \/\/ \u5168\u5c40\u53d8\u91cf<\/p>\n<p>int g_howMuchMoney; \/\/ \u5168\u5c40\u53d8\u91cf<\/p>\n<p>\u00a0<\/p>\n<p>\u25cf\u3010\u89c4\u52193-2-6\u3011\u7c7b\u7684\u6570\u636e\u6210\u5458\u52a0\u524d\u7f00m_\uff08\u8868\u793amember\uff09\uff0c\u8fd9\u6837\u53ef\u4ee5\u907f\u514d\u6570\u636e\u6210\u5458\u4e0e\u6210\u5458\u51fd\u6570\u7684\u53c2\u6570\u540c\u540d\u3002<\/p>\n<p>\u4f8b\u5982\uff1a<\/p>\n<p>void Object::SetValue(int width, int height)<\/p>\n<p>{<\/p>\n<p>m_width = width;<\/p>\n<p>m_height = height;<\/p>\n<p>}<\/p>\n<p>\u00a0<\/p>\n<p>\n\u25cf\u3010\u89c4\u52193-2-7\u3011\u4e3a\u4e86\u9632\u6b62\u67d0\u4e00\u8f6f\u4ef6\u5e93\u4e2d\u7684\u4e00\u4e9b\u6807\u8bc6\u7b26\u548c\u5176\u5b83\u8f6f\u4ef6\u5e93\u4e2d\u7684\u51b2\u7a81\uff0c\u53ef\u4ee5\u4e3a\u5404\u79cd\u6807\u8bc6\u7b26\u52a0\u4e0a\u80fd\u53cd\u6620\u8f6f\u4ef6\u6027\u8d28\u7684\u524d\u7f00\u3002\u4f8b\u5982\u4e09\u7ef4\u56fe\u5f62\u6807\u51c6OpenGL\u7684\u6240\u6709\u5e93\u51fd\u6570\u5747\u4ee5gl\u5f00\u5934\uff0c\u6240\u6709\u5e38\u91cf\uff08\u6216\u5b8f\u5b9a\u4e49\uff09\u5747\u4ee5GL\u5f00\u5934\u3002<\/p>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u9ad8\u8d28\u91cfC++\u6559\u7a0b &#8212; \u7b2c3\u7ae0 \u547d\u540d\u89c4\u5219 \u6765\u6e90:www.vcworld.net\u3000 \u6bd4\u8f83\u8457\u540d\u7684\u547d\u540d\u89c4\u5219\u5f53\u63a8Mic &hellip; <a href=\"https:\/\/www.keyboardmeow.com\/?p=29\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u201c\u9ad8\u8d28\u91cfC++\u6559\u7a0b &#8212; \u7b2c3\u7ae0 \u547d\u540d\u89c4\u5219\u201d<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15],"tags":[24,83,103,105,109,112,147],"class_list":["post-29","post","type-post","status-publish","format-standard","hentry","category-c","tag-c","tag-it","tag-103","tag-105","tag-109","tag-112","tag-147"],"_links":{"self":[{"href":"https:\/\/www.keyboardmeow.com\/index.php?rest_route=\/wp\/v2\/posts\/29","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.keyboardmeow.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.keyboardmeow.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.keyboardmeow.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.keyboardmeow.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=29"}],"version-history":[{"count":0,"href":"https:\/\/www.keyboardmeow.com\/index.php?rest_route=\/wp\/v2\/posts\/29\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.keyboardmeow.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=29"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.keyboardmeow.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=29"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.keyboardmeow.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=29"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}