{"id":88431,"date":"2020-02-14T14:12:12","date_gmt":"2020-02-14T06:12:12","guid":{"rendered":"http:\/\/4563.org\/?p=88431"},"modified":"2020-02-14T14:12:12","modified_gmt":"2020-02-14T06:12:12","slug":"c%e5%8a%a8%e6%80%81%e9%93%be%e6%8e%a5%e5%ba%93%e7%9a%84%e9%97%ae%e9%a2%98","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=88431","title":{"rendered":"c++\u52a8\u6001\u94fe\u63a5\u5e93\u7684\u95ee\u9898"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  c++\u52a8\u6001\u94fe\u63a5\u5e93\u7684\u95ee\u9898               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : a1lenyang <\/span>  <span><i><\/i> 18<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<pre><code>\/\/\u5934\u6587\u4ef6 TaxCaculator.h class _declspec(dllexport) TaxCalculator { private:     double income;     double taxRate; public:   int a;   int b;     TaxCalculator(double income, double taxRate);     ~TaxCalculator();     virtual double calculate(); }; extern \"C\" _declspec(dllexport) TaxCalculator* CreateObjet (double income, double taxRate); <\/code><\/pre>\n<pre><code>\/\/\u5b9e\u73b0\u6587\u4ef6 TaxCaculator.cpp #include \"TaxCaculator.hpp\" TaxCalculator::TaxCalculator(double income, double taxRate){     this -&gt; income = income;     this -&gt; taxRate = taxRate;    a = 2;    b = 5; } TaxCalculator::~TaxCalculator(){      } double TaxCalculator::calculate(){     return (income * taxRate); } <\/code><\/pre>\n<ul>\n<li>\u4ee5\u4e0a\u7a0b\u5e8f\u751f\u6210 dll\uff0c\u7136\u540e\u5728\u540c\u4e00\u4e2a\u7f16\u8bd1\u5668\u4e2d\u5efa\u7acb\u4e00\u4e2a\u65b0\u7684\u5ba2\u6237\u6587\u4ef6\u8c03\u7528<\/li>\n<\/ul>\n<pre><code>#include \"TaxCalculator.h\" #include &lt;iostream&gt; int main() {   TaxCaculator* caclulator = CreateObject(1000, 0.3);     int a = calculator -&gt; a;     int b = calculator -&gt; b;   return 0; }  <\/code><\/pre>\n<ul>\n<li>\u5728 dll \u6587\u4ef6\u4e2d\uff0c\u6539\u53d8 a \u548c b \u5b9a\u4e49\u7684\u4f4d\u7f6e\uff0c\u7136\u540e\u91cd\u65b0\u7f16\u8bd1\uff0c**\u5ba2\u6237\u6587\u4ef6\u91cd\u65b0\u8c03\u7528\u65b0\u7684 dll \u6587\u4ef6\uff0c\u4e3a\u4ec0\u4e48\u4e24\u6b21\u7684\u7ed3\u679c\u662f\u98a0\u5012\u7684\uff1f**\u8fd9\u91cc\u4e0d\u662f\u5f88\u7406\u89e3\u3002<\/li>\n<li>\u540c\u7406\uff0c\u5728 dll \u6587\u4ef6\u4e2d\u5b9a\u4e49\u4e24\u4e2a\u865a\u51fd\u6570<\/li>\n<\/ul>\n<pre><code>    virtual int fa();       virtual int fb();   <\/code><\/pre>\n<p>\u5206\u522b\u5b9e\u73b0\u4e4b\u3002 \u7f16\u8bd1\u670d\u52a1\u5668\u7aef\u548c\u5ba2\u6237\u7aef\u3002\u5f97\u5230\u7248\u672c 1.<\/p>\n<p>\u6539\u53d8\u5b9a\u4e49\u987a\u5e8f:<\/p>\n<pre><code>virtual int fb();  virtual int fa(); <\/code><\/pre>\n<p>\u7f16\u8bd1\u670d\u52a1\u5668\u7aef\u548c\u5ba2\u6237\u7aef\u3002\u5f97\u5230\u7248\u672c 2. \u6253\u4e71\u7248\u672c\u7684\u642d\u914d\u987a\u5e8f\uff0c\u8c03\u7528\u5c06\u51fa\u73b0\u9519\u4e71\u3002\u8fd9\u53c8\u662f\u4e3a\u4ec0\u4e48\uff1f<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>6<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"1145042\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : codehz <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u56e0\u4e3a\u865a\u51fd\u6570\u662f\u6309\u58f0\u660e\u987a\u5e8f\u4fdd\u5b58\u5728\u865a\u8868\u91cc\u7684\uff0c\u6240\u4ee5\u5b9e\u9645\u4e0a\u4f60\u5199 x.fa()\u7684\u65f6\u5019\u7f16\u8bd1\u5668\u5c31\u4f1a\u751f\u6210\u5bf9\u865a\u8868\u7b2c\u4e00\u4e2a\u51fd\u6570\u7684\u8c03\u7528\uff0c\u6240\u4ee5\u4f60\u6539\u53d8\u58f0\u660e\u987a\u5e8f\u5c31\u4f1a\u5bfc\u81f4\u8c03\u7528\u9519\u8bef\u51fd\u6570                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1145043\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : catcn <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4e0d\u8981\u5bfc\u51fa c++                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1145044\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : rigortek <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u52a0 log \u8c03\u8bd5\u4e00\u4e0b\u770b\u4e3a\u4ec0\u4e48\u9519\u4e71                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1145045\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : a1lenyang <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @codehz \u597d\u7684\uff0c\u865a\u51fd\u6570\u660e\u767d\u4e86\uff0c\u539f\u6765\u662f\u6211\u5fd8\u8bb0\u4e86\u5934\u6587\u4ef6\u662f\u6ca1\u6709\u6539\u53d8\u7684\uff0c\u53ea\u662f\u6539\u53d8\u4e86 dll \u7684\u7248\u672c\u3002<br \/>\u865a\u51fd\u6570\u7684\u987a\u5e8f\u6709\u865a\u8868\u4fdd\u5b58\uff0c\u8bf7\u95ee\u53d8\u91cf a, b \u4e5f\u662f\u4ee5\u67d0\u79cd\u987a\u5e8f\u5b58\u50a8\u7684\u5417\uff1f                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1145046\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : codehz <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @a1lenyang \u53d8\u91cf\u987a\u5e8f\u662f\u4e0d\u53d8\u7684\uff0c\u4f46\u662f\u8981\u6ce8\u610f\u865a\u8868\u4f1a\u5728\u5f00\u5934\u989d\u5916\u5360\u7528\u4e00\u4e2a\u6307\u9488\uff0c\u591a\u91cd\u7ee7\u627f\u7684\u65f6\u5019\u5219\u6709\u53ef\u80fd\u4f1a\u66f4\u591a\uff0c\u56e0\u6b64\u6700\u597d\u6bcf\u6b21\u53d8\u66f4\u90fd\u540c\u65f6\u66f4\u65b0\u5934\u6587\u4ef6\u5e76\u91cd\u65b0\u7f16\u8bd1\u5176\u4ed6\u4f9d\u8d56\u7684\u5e93                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1145047\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : a1lenyang <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @codehz \u660e\u767d\u4e86\uff0c\u8c22\u8c22                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>c++\u52a8\u6001\u94fe\u63a5\u5e93\u7684\u95ee\u9898 \u8cc7\u6df1\u5927\u4f6c &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/88431"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=88431"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/88431\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=88431"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=88431"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=88431"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}