{"id":4939,"date":"2018-08-07T16:57:36","date_gmt":"2018-08-07T08:57:36","guid":{"rendered":"http:\/\/blog.qdac.cc\/?p=4939"},"modified":"2018-08-07T16:57:36","modified_gmt":"2018-08-07T08:57:36","slug":"%e6%95%99%e7%a8%8b%e5%88%a4%e6%96%ad%e4%b8%a4%e4%b8%aa%e4%b8%8d%e5%90%8c%e7%9a%84%e6%8e%a5%e5%8f%a3%e5%ae%9e%e4%be%8b%e6%98%af%e5%90%a6%e6%98%af%e5%90%8c%e4%b8%80%e4%b8%aa%e5%af%b9%e8%b1%a1","status":"publish","type":"post","link":"https:\/\/blog.qdac.cc\/?p=4939","title":{"rendered":"[\u6559\u7a0b]\u5224\u65ad\u4e24\u4e2a\u4e0d\u540c\u7684\u63a5\u53e3\u5b9e\u4f8b\u662f\u5426\u662f\u540c\u4e00\u4e2a\u5bf9\u8c61"},"content":{"rendered":"<p>\u5982\u679c\u4e00\u4e2a\u5bf9\u8c61\u652f\u6301\u591a\u4e2a\u63a5\u53e3\uff0c\u5f53\u6211\u4eec\u83b7\u53d6\u5176\u652f\u6301\u7684\u4e0d\u540c\u63a5\u53e3\u7684\u5b9e\u4f8b\u65f6\uff0c\u5c31\u4f1a\u5f97\u5230\u4e0d\u540c\u7684\u5730\u5740\uff0c\u6bd4\u5982\uff1a<\/p>\n<pre class=\"lang:delphi decode:true \">type\r\n  IA=interface\r\n  ['{CB36F22E-E44C-4842-8198-7487806A3617}']\r\n  ...\r\n  end;\r\n  \r\n  IB=interface\r\n  ['{06949AE4-97F9-48C9-9E47-21E29F396DF7}']\r\n  ...\r\n  end;\r\n  \r\n  TABObject=class(TInterfacedObject,IA,IB)\r\n  ...\r\n  end;<\/pre>\n<p>\u6211\u4eec\u5047\u8bbe\u5bf9\u8c61 TABObject \u7684\u5b9e\u4f8b ab\uff0c\u5f53\u6211\u4eec\u5199\u4e0b\u7c7b\u4f3c\u4e8e\u4e0b\u9762\u7684\u4ee3\u7801\u65f6\uff1a<\/p>\n<pre class=\"lang:delphi decode:true \">var\r\n  A:IA;\r\n  B:IB;\r\nbegin\r\n  A:=ab;\r\n  B:=ab;\r\n  if Pointer(A)=Pointer(B) then\r\n    ....\r\nend;<\/pre>\n<p>\u5728\u5b9e\u9645\u8fd0\u884c\u4e2d\uff0cA \u548c B \u867d\u7136\u662f\u540c\u4e00\u4e2a\u5b9e\u4f8b ab\uff0c\u4f46\u5f53\u6211\u4eec\u8c03\u7528\u65f6\uff0c\u4f1a\u53d1\u73b0 A \u548c B \u5e76\u4e0d\u662f\u540c\u4e00\u4e2a\u5730\u5740\uff0c\u6240\u4ee5 if \u8bed\u53e5\u6761\u4ef6\u5224\u65ad\u6c38\u8fdc\u662f\u5047\uff0c\u5982\u679c\u6211\u4eec\u9700\u8981\u5224\u65ad\u4e24\u4e2a\u662f\u5426\u662f\u540c\u4e00\u4e2a\u5bf9\u8c61\u751f\u6210\u7684\uff0c\u6709\u4e24\u79cd\u529e\u6cd5\uff1a<\/p>\n<p>1\u3001\u8f6c\u6362\u4e3a\u5bf9\u8c61\u540e\u518d\u6bd4\u8f83<\/p>\n<p>\u4e0e\u63a5\u53e3\u4e0d\u540c\uff0cDelphi \u4e2d\u7684\u5bf9\u8c61\u65e0\u8bba\u662f\u5b50\u7c7b\u8fd8\u662f\u7236\u7c7b\uff0c\u4f7f\u7528\u7684\u5730\u5740\u90fd\u662f\u540c\u4e00\u4e2a\uff0c\u6240\u4ee5\u4e0b\u9762\u7684\u4ee3\u7801\u662f\u6ca1\u6709\u95ee\u9898\u7684\uff0c\u4e0d\u8fc7\u4ec5\u652f\u6301 Delphi \u7684\u5bf9\u8c61\u5b9e\u4f8b\uff1a<\/p>\n<blockquote><p>if (A as TObject)=(B as TObject) then<\/p><\/blockquote>\n<p>2\u3001\u8f6c\u6362\u4e3a\u57fa\u51c6\u7684 IInterface \uff0c\u4e5f\u5c31\u662f IUnknown \u63a5\u53e3\uff0c\u540c\u4e00\u4e2a\u5bf9\u8c61\u5982\u679c\u67e5\u8be2 IInterface \u63a5\u53e3\u8fd4\u56de\u7684\u5730\u5740\u662f\u76f8\u540c\u7684\u3002\u4e0d\u8981\u8bd5\u56fe\u7528\u4e0b\u9762\u7684\u4ee3\u7801\uff1a<\/p>\n<blockquote><p>if IInterface(ARoot)=IInterface(FDocument.Units) then<\/p><\/blockquote>\n<p>\u8fd9\u4ee3\u7801\u5e76\u4e0d\u4f1a\u89e6\u53d1 QueryInterface \u67e5\u8be2\u6700\u57fa\u51c6\u7684 IInterface \u63a5\u53e3\u5730\u5740\uff0c\u6240\u4ee5\u4e00\u6837\u4e0d\u884c\u3002\u6240\u4ee5\u6b63\u786e\u7684\u4ee3\u7801\u662f\uff1a<\/p>\n<blockquote><p>if (A as IInterface)=(B as IInterface) then<\/p><\/blockquote>\n<p>\u597d\u5427\uff0c\u5230\u73b0\u5728\u8fd9\u4e00\u6b65\uff0c\u57fa\u672c\u4e0a\u5c31\u5dee\u4e0d\u591a\u4e86\u3002\u8fdb\u4e00\u6b65\u5b8c\u5584\u4e0b\u7684\u8bdd\uff0c\u81ea\u5df1\u60f3\u5427\u3002<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u679c\u4e00\u4e2a\u5bf9\u8c61\u652f\u6301\u591a\u4e2a\u63a5\u53e3\uff0c\u5f53\u6211\u4eec\u83b7\u53d6\u5176\u652f [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[8,603],"tags":[],"class_list":["post-4939","post","type-post","status-publish","format-standard","hentry","category-delphi","category-603"],"views":2953,"_links":{"self":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/4939","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4939"}],"version-history":[{"count":1,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/4939\/revisions"}],"predecessor-version":[{"id":4940,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/4939\/revisions\/4940"}],"wp:attachment":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4939"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4939"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4939"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}