{"rsdb":{"rid":"244437","subhead":"","postdate":"0","aid":"168212","fid":"49","uid":"1","topic":"1","content":"
\r\nclass A {\r\n public:\r\n int a;\r\n A(int p):a(p) {}\r\n}\r\n\r\nclass B : public A {\r\n public:\r\n int b;\r\n B(int p1, int p2):A(p1), b(p2) {}\r\n}\r\n\r\n\/\/B\u7684\u6784\u9020\u51fd\u6570\u5148\u7531A\u7684\u6784\u9020\u51fd\u6570\u521d\u59cb\u5316a\uff0c\u7136\u540e\u6267\u884cA\u7684\u6784\u9020\u51fd\u6570\u4f53\uff0c\u63a5\u7740\u521d\u59cb\u5316b\uff0c\u6700\u540e\u6267\u884cB\u7684\u6784\u9020\u51fd\u6570\u4f53\r\n\/\/\u6d3e\u751f\u7c7b\u58f0\u660e\u65f6\uff0c\u58f0\u660e\u4e2d\u5305\u542b\u7c7b\u540d\u4f46\u662f\u4e0d\u5305\u542b\u5b83\u7684\u6d3e\u751f\u5217\u8868\r\nclass B : public A;\/\/\u9519\u8bef\r\nclass B;\/\/\u6b63\u786e<\/pre> \u5982\u679c\u67d0\u4e2a\u7c7b\u88ab\u5f53\u4f5c\u57fa\u7c7b\uff0c\u5219\u8be5\u7c7b\u5fc5\u987b\u88ab\u5b9a\u4e49\uff0c\u800c\u4e0d\u80fd\u4ec5\u4ec5\u88ab\u58f0\u660e\u3002 \n\r\nclass A; \/\/\u4ec5\u4ec5\u58f0\u660e\u4e86A\u7c7b\r\nclass B : public A {\r\n ...\r\n} \/\/\u9519\u8bef\uff0cA\u7c7b\u5fc5\u987b\u88ab\u5b9a\u4e49<\/pre> \u4ece\u6d3e\u751f\u7c7b\u5411\u57fa\u7c7b\u7684\u7c7b\u578b\u8f6c\u6362\u53ea\u5bf9\u6307\u9488\u6216\u5f15\u7528\u7c7b\u578b\u6709\u6548 \u57fa\u7c7b\u5411\u6d3e\u751f\u7c7b\u4e0d\u5b58\u5728\u9690\u5f0f\u7684\u7c7b\u578b\u8f6c\u6362 \u5f53\u6211\u4eec\u7528\u4e00\u4e2a\u6d3e\u751f\u7c7b\u5bf9\u8c61\u4e3a\u4e00\u4e2a\u57fa\u7c7b\u5bf9\u8c61\u521d\u59cb\u5316\u6216\u8d4b\u503c\u65f6\uff0c\u53ea\u6709\u8be5\u6d3e\u751f\u7c7b\u5bf9\u8c61\u4e2d\u57fa\u7c7b\u7684\u90e8\u5206\u4f1a\u88ab\u62f7\u8d1d\u3001\u79fb\u52a8\u3001\u8d4b\u503c\uff0c\u5b83\u7684\u6d3e\u751f\u7c7b\u90e8\u5206\u5c06\u88ab\u5ffd\u7565\u6389\u3002\u6240\u4ee5\u5f97\u5230\u7684\u57fa\u7c7b\u5bf9\u8c61\u65e0\u6cd5\u5f3a\u5236\u8f6c\u6362\u6210\u6d3e\u751f\u7c7b\u5bf9\u8c61\u3002 \n\r\nclass A {}\r\nclass B : public A {}\r\nB b;\r\nA a(b);\/\/\u5b9e\u9645\u4e0a\uff0c\u8c03\u7528\u7684\u662f\u62f7\u8d1d\u6784\u9020\u51fd\u6570\uff0c\u5373A::A(const A&)\r\na = b;\/\/\u5b9e\u9645\u4e0a\uff0c\u8c03\u7528\u7684\u662f\u62f7\u8d1d\u8d4b\u503c\u8fd0\u7b97\u7b26\uff0c\u5373A::operator=(const A&)<\/pre> \u5217\u8868\u5185\u5bb9 \n<\/div>","orderid":"0","title":"C++\u9762\u5411\u5bf9\u8c61\u7a0b\u5e8f\u8bbe\u8ba1\u8be6\u60c5","smalltitle":"","mid":"0","fname":"c++\u7f16\u7a0b\u57fa\u7840","special_id":"0","bak_id":"0","info":"0","hits":"173","pages":"1","comments":"0","posttime":"2018-02-13 12:56:09","list":"1518497769","username":"admin","author":"","copyfrom":"","copyfromurl":"","titlecolor":"","fonttype":"0","titleicon":"0","picurl":"https:\/\/www.cppentry.com\/upload_files\/","ispic":"0","yz":"1","yzer":"","yztime":"0","levels":"0","levelstime":"0","keywords":"\u9762\u5411<\/A> \u5bf9\u8c61<\/A> \u7a0b\u5e8f\u8bbe\u8ba1<\/A> \u8be6\u60c5<\/A>","jumpurl":"","iframeurl":"","style":"","template":"a:3:{s:4:\"head\";s:0:\"\";s:4:\"foot\";s:0:\"\";s:8:\"bencandy\";s:0:\"\";}","target":"0","ip":"113.87.122.142","lastfid":"0","money":"0","buyuser":"","passwd":"","allowdown":"","allowview":"","editer":"","edittime":"0","begintime":"0","endtime":"0","description":"C++\u9762\u5411\u5bf9\u8c61\u7a0b\u5e8f\u8bbe\u8ba1\u8be6\u60c5","lastview":"1714040354","digg_num":"2","digg_time":"1711463490","forbidcomment":"0","ifvote":"0","heart":"","htmlname":"","city_id":"0"},"page":"1"}