{"id":7679,"date":"2009-04-08T16:34:31","date_gmt":"2009-04-08T13:34:31","guid":{"rendered":"http:\/\/studentpmr.ru\/?p=7679"},"modified":"2009-04-08T16:34:31","modified_gmt":"2009-04-08T13:34:31","slug":"%d0%bf%d1%80%d0%be%d1%81%d1%82%d0%be%d0%b5-%d0%b8-%d0%bc%d0%bd%d0%be%d0%b6%d0%b5%d1%81%d1%82%d0%b2%d0%b5%d0%bd%d0%bd%d0%be%d0%b5-%d0%bd%d0%b0%d1%81%d0%bb%d0%b5%d0%b4%d0%be%d0%b2%d0%b0%d0%bd%d0%b8-3","status":"publish","type":"post","link":"http:\/\/studentpmr.ru\/?p=7679","title":{"rendered":"\u041f\u0440\u043e\u0441\u0442\u043e\u0435 \u0438 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435"},"content":{"rendered":"<h4><a name=\"_Toc457622512\"><\/a><a name=\"_Toc457368839\"><\/a><a name=\"_Toc457368075\">3.1. \u041f\u0440\u043e\u0441\u0442\u043e\u0435 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435.<\/a><\/h4>\n<p>\u041f\u0440\u043e\u0441\u0442\u043e\u0435 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0440\u043e\u0434\u0441\u0442\u0432\u043e \u043c\u0435\u0436\u0434\u0443 \u0434\u0432\u0443\u043c\u044f \u043a\u043b\u0430\u0441\u0441\u0430\u043c\u0438: \u043e\u0434\u0438\u043d \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0432\u0442\u043e\u0440\u043e\u043c\u0443. \u041a\u043b\u0430\u0441\u0441, \u043d\u0430\u0445\u043e \u0434\u044f\u0449\u0438\u0439\u0441\u044f \u043d\u0430 \u0432\u0435\u0440\u0448\u0438\u043d\u0435 \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u0438, \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0431\u0430\u0437\u043e\u0432\u044b\u043c \u043a\u043b\u0430\u0441\u0441\u043e\u043c. \u041f\u0440\u043e\u0447\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u044b \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u044b\u043c\u0438 \u043a\u043b\u0430\u0441\u0441\u0430\u043c\u0438. \u0418\u0437 \u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u043c\u043e\u0433\u0443\u0442 \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043c\u043d\u043e\u0433\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u044b, \u043d\u043e \u0434\u0430\u0436\u0435 \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0439 \u0432\u0438\u0434 \u0432\u0437\u0430\u0438\u043c\u043e\u0441\u0432\u044f\u0437\u0438 \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435\u043c.<\/p>\n<p>\u0411\u0430\u0437\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u0447\u0430\u0441\u0442\u043e \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442 \u043f\u0440\u0435\u0434\u043a\u043e\u043c, \u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 &#8212; \u043f\u043e\u0442\u043e\u043c\u043a\u043e\u043c.<\/p>\n<p> <!--more-->  <\/p>\n<p>\u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0438\u0437 \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u0434\u0430\u043d\u043d\u044b\u0435-\u0447\u043b\u0435\u043d\u044b \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438-\u0447\u043b\u0435\u043d\u044b, \u043d\u043e \u043d\u0435 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u044b \u0438 \u0434\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u044b.<\/p>\n<p>class Tbase { \/\/\u0411\u0430\u0437\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441<\/p>\n<p>private:<\/p>\n<p>int count;<\/p>\n<p>public:<\/p>\n<p>TBase() {count = 0;}<\/p>\n<p>void SetCount(int n) {count = n;}<\/p>\n<p>int GetCount(void) {return count;}<\/p>\n<p>};<\/p>\n<p>class TDerived: public TBase { \/\/\u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441<\/p>\n<p>public:<\/p>\n<p>TDerived(): Tbase() {}<\/p>\n<p>void ChangeCount(int n) {SetCount(GetCount() + n);}<\/p>\n<p>};<\/p>\n<p>\u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u043d\u0430\u0437\u0432\u0430\u043d TDerived. \u0417\u0430 \u0438\u043c\u0435\u043d\u0435\u043c \u0441\u043b\u0435-\u0434\u0443\u0435\u0442 \u0434\u0432\u043e\u0435\u0442\u043e\u0447\u0438\u0435 \u0438 \u043e\u0434\u043d\u043e \u0438\u0437 \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0445 \u0441\u043b\u043e\u0432 &#8212; public, protected, private. \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u0438\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0438\u043c\u044f \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 TBase. \u041e\u0442\u043a\u0440\u044b\u0442\u044b\u0435 \u0447\u043b\u0435\u043d\u044b \u043e\u0442\u043a\u0440\u044b\u0442\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u043e\u0441\u0442\u0430\u044e\u0442\u0441\u044f \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u043c\u0438 \u0432 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0435:<\/p>\n<p>class TDerived: public TBase {}<\/p>\n<p>\u0412\u0441\u0435 \u0437\u0430\u043a\u0440\u044b\u0442\u044b\u0435 \u0447\u043b\u0435\u043d\u044b Tbase \u043e\u0441\u0442\u0430\u044e\u0442\u0441\u044f \u0437\u0430\u043a\u0440\u044b\u0442\u044b\u043c\u0438 \u0438 \u0432 Tderived \u043d\u0435\u043b\u044c\u0437\u044f \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043a \u043d\u0438\u043c \u0434\u043e\u0441\u0442\u0443\u043f. \u041c\u043e\u0436\u043d\u043e \u043e\u0431\u044a\u044f\u0432\u0438\u0442\u044c \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u0437\u0430\u043a\u0440\u044b\u0442\u044b\u043c:<\/p>\n<p>class TDerived: private TBase {}<\/p>\n<p>\u0412\u0441\u0435 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0435 \u0447\u043b\u0435\u043d\u044b \u0432 \u0431\u0430\u0437\u043e\u0432\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0435 \u0441\u0442\u0430\u043d\u043e\u0432\u044f\u0442\u0441\u044f \u0437\u0430\u043a\u0440\u044b-\u0442\u044b\u043c\u0438 \u0432 TDerived. \u041f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f TDerived \u043d\u0435 \u0441\u043c\u043e-\u0433\u0443\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u0432 \u0447\u043b\u0435\u043d\u0430\u043c TBase. \u041e\u0431\u044b\u0447\u043d\u043e \u0432 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0435 \u0435\u0441\u0442\u044c \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440, \u0435\u0441\u043b\u0438 \u043e\u043d \u0431\u044b\u043b \u0432 \u0431\u0430\u0437\u043e\u0432\u043e\u043c. \u041e\u043d \u0434\u043e\u043b\u0436\u0435\u043d \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430:<\/p>\n<p>TDerived(): TBase() {}<\/p>\n<p>\u041a\u0440\u043e\u043c\u0435 \u044d\u0442\u043e\u0433\u043e \u0432 \u043d\u0435\u043c \u043c\u043e\u0433\u0443\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<p>TDerived():TBase() {cout &lt;&lt;&quot; I am being initialized&quot; &lt;&lt;endl;}<\/p>\n<p>\u041c\u043e\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e:<\/p>\n<p>TDerived::TDerived()<\/p>\n<p>: TBase()<\/p>\n<p>{ \/\/ \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u044b<\/p>\n<p>}<\/p>\n<p>\u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u0442 count \u0438\u0437 \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430, \u043d\u043e \u0442\u0430\u043a \u043a\u0430\u043a \u043e\u043d \u0437\u0430\u043a\u0440\u044b\u0442 \u0432 TBase \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043d\u0435\u043c\u0443 \u0432\u043e\u0437\u043c\u043e\u0436\u0435\u043d \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0435\u0440\u0435\u0437 \u0444\u0443\u043d\u043a\u0446\u0438\u0438-\u0447\u043b\u0435\u043d\u044b \u043a\u043b\u0430\u0441\u0441\u0430 TBase. \u0412 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0435 \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u043a \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c-\u0447\u043b\u0435\u043d\u0430\u043c \u043a\u043b\u0430\u0441\u0441\u0430 TBase:<\/p>\n<p>void ChangeCount(int n) {SetCount(GetCount() +n);}<\/p>\n<p>\u0417\u0430\u0449\u0438\u0449\u0435\u043d\u043d\u044b\u0435 \u0447\u043b\u0435\u043d\u044b \u043a\u043b\u0430\u0441\u0441\u0430 &#8212; \u044d\u0442\u043e \u043d\u0435\u0447\u0442\u043e \u0441\u0440\u0435\u0434\u043d\u0435\u0435 \u043c\u0435\u0436\u0434\u0443 \u043e\u0442-\u043a\u0440\u044b\u0442\u044b\u043c\u0438 \u0438 \u0437\u0430\u043a\u0440\u044b\u0442\u044b\u043c\u0438 \u0447\u043b\u0435\u043d\u0430\u043c\u0438. \u041f\u043e\u0434\u043e\u0431\u043d\u043e \u0437\u0430\u043a\u0440\u044b\u0442\u044b\u043c \u043e\u043d\u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c-\u0447\u043b\u0435\u043d\u0430\u043c \u043a\u043b\u0430\u0441\u0441\u0430. \u0412\u043d\u0435 \u043a\u043b\u0430\u0441\u0441\u0430 \u043e\u043d\u0438 \u043d\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b. \u041f\u043e\u0434\u043e\u0431\u043d\u043e \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u043c \u043e\u043d\u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c-\u0447\u043b\u0435\u043d\u0430\u043c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432.<\/p>\n<p>&#8212; \u0437\u0430\u043a\u0440\u044b\u0442\u044b\u0435 \u0447\u043b\u0435\u043d\u044b \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0442\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0435, \u0432 \u043a\u043e\u0442\u043e-\u0440\u043e\u043c \u043e\u043d\u0438 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u044b;<\/p>\n<p>&#8212; \u0437\u0430\u0449\u0438\u0449\u0435\u043d\u043d\u044b\u0435 \u0447\u043b\u0435\u043d\u044b \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u0447\u043b\u0435\u043d\u0430\u043c \u0438\u0445 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0438 \u0432\u0441\u0435\u043c \u0447\u043b\u0435\u043d\u0430\u043c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432;<\/p>\n<p>&#8212; \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0435 \u0447\u043b\u0435\u043d\u044b \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u0447\u043b\u0435\u043d\u0430\u043c \u0438\u0445 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430, \u0447\u043b\u0435\u043d\u0430\u043c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0438 \u0432\u0441\u0435\u043c \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c \u044d\u0442\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430.<\/p>\n<p>\u0421\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u044b (public, private, protected) \u0432\u043b\u0438\u044f\u044e\u0442 \u043d\u0430 \u0441\u0442\u0430\u0442\u0443\u0441 \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u043c\u044b\u0445 \u0447\u043b\u0435\u043d\u043e\u0432:<\/p>\n<p>&#8212; \u0447\u043b\u0435\u043d\u044b \u043e\u0442\u043a\u0440\u044b\u0442\u043e\u0433\u043e \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0432 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044e\u0442 \u0441\u0432\u043e\u0438 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u0430;<\/p>\n<p>&#8212; \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0435 \u0447\u043b\u0435\u043d\u044b \u0437\u0430\u0449\u0438\u0449\u0435\u043d\u043d\u043e\u0433\u043e \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0441\u0442\u0430\u043d\u043e\u0432\u044f\u0442\u0441\u044f \u0437\u0430\u043a\u0440\u044b\u0442\u044b\u043c\u0438 \u0432 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0435. \u0417\u0430\u0449\u0438\u0449\u0435\u043d\u043d\u044b\u0435 \u0438 \u0437\u0430\u043a\u0440\u044b\u0442\u044b\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044e\u0442 \u0441\u0432\u043e\u0438 \u043f\u0435\u0440\u0432\u043e\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0435 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438;<\/p>\n<p>&#8212; \u0432\u0441\u0435 \u0447\u043b\u0435\u043d\u044b \u0437\u0430\u043a\u0440\u044b\u0442\u043e\u0433\u043e \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0441\u0442\u0430\u043d\u043e\u0432\u044f\u0442\u0441\u044f \u0437\u0430\u043a\u0440\u044b\u0442\u044b\u043c\u0438 \u0432 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0435 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e \u043e\u0442 \u0438\u0445 \u043f\u0435\u0440\u0432\u043e-\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0439 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u0430. <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0445\u043e\u0442\u0438\u0442\u0435 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u043c\u0438 \u0432 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0437 \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u043c\u044b\u0445 \u0447\u043b\u0435\u043d\u043e\u0432, \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0431\u043e-\u0440\u043e\u0447\u043d\u043e \u043a\u0432\u0430\u043b\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0434\u0438\u043d \u0438\u043b\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0438\u0437 \u043d\u0438\u0445.<\/p>\n<p>class A {<\/p>\n<p>public:<\/p>\n<p>int x;<\/p>\n<p>A() { x=0;}<\/p>\n<p>void Display(void) { count &lt;&lt; &quot;x = &quot; &lt;&lt; x &lt;&lt; endl;}<\/p>\n<p>};<\/p>\n<p>class B: private A {<\/p>\n<p>public:<\/p>\n<p>A::Display; \/\/ \u043a\u0432\u0430\u043b\u0438\u0444\u0438\u0446\u0438\u0440\u0443\u0435\u043c \u043a\u0430\u043a \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0439 \u0447\u043b\u0435\u043d \u043a\u043b\u0430\u0441\u0441\u0430<\/p>\n<p>B(): A() {}<\/p>\n<p>};<\/p>\n<p>\u0412 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0435 \u0434\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u043d\u0443\u0436\u0435\u043d \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0447\u0442\u043e-\u0442\u043e \u0443\u0434\u0430\u043b\u044f\u0442\u044c.<\/p>\n<p>\/\/ \u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 1<\/p>\n<p>#include &lt;iostream.h&gt;<\/p>\n<p>#include &lt;string.h&gt;<\/p>\n<p>class TBase { \/\/\u0411\u0430\u0437\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441<\/p>\n<p>private:<\/p>\n<p>char *basep;<\/p>\n<p>public:<\/p>\n<p>TBase(const char *s) {basep = strdup(s); }<\/p>\n<p>~TBase() {delete basep;}<\/p>\n<p>const char *GetStr(void) { return basep; }<\/p>\n<p>};<\/p>\n<p>class TDerived: public TBase { \/\/\u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441<\/p>\n<p>private:<\/p>\n<p>char *uppercasep;<\/p>\n<p>public:<\/p>\n<p>TDerived(const char* s): TBase(s) { uppercasep = strupr(strdup(s));}<\/p>\n<p>~TDerived() {delete uppercasep;}<\/p>\n<p>const char *GetUStr(void) { return uppercasep;}<\/p>\n<p>};<\/p>\n<p>void main()<\/p>\n<p>{<\/p>\n<p>TBase president(&quot;George Washington&quot;);<\/p>\n<p>cout &lt;&lt; &quot;Original string: &quot; &lt;&lt; president.GetStr() &lt;&lt; endl;<\/p>\n<p>TDerived pres(&quot;George Washington&quot;);<\/p>\n<p>cout &lt;&lt; &quot;Uppercase string:&quot; &lt;&lt; pres.GetUStr() &lt;&lt; endl;<\/p>\n<p>}<\/p>\n<p>\u0412 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0435 \u043e\u0431\u044b\u0447\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043d\u043e\u0432\u044b\u0435 \u0434\u0430\u043d-\u043d\u044b\u0435 \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438-\u0447\u043b\u0435\u043d\u044b. \u041e\u0434\u043d\u0430\u043a\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0437\u0430\u043c\u0435-\u0449\u0435\u043d\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0439-\u0447\u043b\u0435\u043d\u043e\u0432, \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043e\u0442 \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<p>\/\/\u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 2<\/p>\n<p>#include &lt;iostream.h&gt;<\/p>\n<p>#include &lt;string.h&gt;<\/p>\n<p>class TBase { \/\/\u0411\u0430\u0437\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441<\/p>\n<p>private:<\/p>\n<p>char *basep;<\/p>\n<p>public:<\/p>\n<p>TBase(const char *s) {basep = strdup(s); }<\/p>\n<p>~TBase() {delete basep;}<\/p>\n<p>void Display(void) { cout &lt;&lt; basep &lt;&lt; endl;}<\/p>\n<p>};<\/p>\n<p>class TState: public TBase { \/\/\u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441<\/p>\n<p>public:<\/p>\n<p><a name=\"_Toc457368895\"><\/a><a name=\"_Toc457368840\"><\/a><a name=\"_Toc457368076\"><\/a><a name=\"_Toc457366730\"><\/a><a name=\"_Toc457366541\"><\/a><a name=\"_Toc457366398\">TState(const char *s):TBase (s) {}<\/a><\/p>\n<p>void Display(void); \/\/ \u0437\u0430\u043c\u0435\u0449\u0430\u044e\u0449\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f<\/p>\n<p>};<\/p>\n<p>void TState::Display(void)<\/p>\n<p>{<\/p>\n<p>cout &lt;&lt; &quot;State: &quot;; \/\/\u041d\u043e\u0432\u044b\u0439 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440<\/p>\n<p>TBase::Display(); \/\/\u0412\u044b\u0437\u043e\u0432 \u0437\u0430\u043c\u0435\u0449\u0435\u043d\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438<\/p>\n<p>}<\/p>\n<p>void main()<\/p>\n<p>{<\/p>\n<p>TState object(&quot;Welcome to Borland C++5 programming!&quot;);<\/p>\n<p>object.Display();<\/p>\n<p>}<\/p>\n<h4><a name=\"_Toc457622513\"><\/a><a name=\"_Toc457368841\"><\/a><a name=\"_Toc457368077\">3.2. \u041c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435<\/a><\/h4>\n<p>\u041f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0431\u0430\u0437\u043e\u0432\u044b\u0445 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u043e: \u0432\u043c\u0435\u0441\u0442\u043e \u0438\u043c\u0435\u043d\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 (\u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u0435\u0433\u043e \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u043c) \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0441\u043f\u0438\u0441\u043e\u043a \u0438\u043c\u0435\u043d, \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u0437\u0430\u043f\u044f\u0442\u044b\u043c\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<p>class A { \/*\u2026*\/ };<\/p>\n<p>class B { \/*\u2026*\/ };<\/p>\n<p>class C: public A, private B { \/*\u2026*\/ };<\/p>\n<p>\u041f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430\u043c \u0431\u0430\u0437\u043e\u0432\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0438\u0437 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0442\u0430\u043a \u0436\u0435 \u043a\u0430\u043a \u0438 \u0440\u0430\u043d\u044c\u0448\u0435:<\/p>\n<p>\u0421::\u0421( int a, char* str) : A(a), B(str) { \/*\u2026*\/ };<\/p>\n","protected":false},"excerpt":{"rendered":"<p>3.1. \u041f\u0440\u043e\u0441\u0442\u043e\u0435 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435. \u041f\u0440\u043e\u0441\u0442\u043e\u0435 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0440\u043e\u0434\u0441\u0442\u0432\u043e \u043c\u0435\u0436\u0434\u0443 \u0434\u0432\u0443\u043c\u044f \u043a\u043b\u0430\u0441\u0441\u0430\u043c\u0438: \u043e\u0434\u0438\u043d \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0432\u0442\u043e\u0440\u043e\u043c\u0443. \u041a\u043b\u0430\u0441\u0441, \u043d\u0430\u0445\u043e \u0434\u044f\u0449\u0438\u0439\u0441\u044f \u043d\u0430 \u0432\u0435\u0440\u0448\u0438\u043d\u0435 \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u0438, \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0431\u0430\u0437\u043e\u0432\u044b\u043c \u043a\u043b\u0430\u0441\u0441\u043e\u043c. \u041f\u0440\u043e\u0447\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u044b \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u044b\u043c\u0438 \u043a\u043b\u0430\u0441\u0441\u0430\u043c\u0438. \u0418\u0437 \u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u043c\u043e\u0433\u0443\u0442 \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043c\u043d\u043e\u0433\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u044b, \u043d\u043e \u0434\u0430\u0436\u0435 \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0439 \u0432\u0438\u0434 \u0432\u0437\u0430\u0438\u043c\u043e\u0441\u0432\u044f\u0437\u0438 \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435\u043c. \u0411\u0430\u0437\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u0447\u0430\u0441\u0442\u043e \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442 \u043f\u0440\u0435\u0434\u043a\u043e\u043c, \u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 <a class=\"readmore\" href=\"http:\/\/studentpmr.ru\/?p=7679\">\u0427\u0438\u0442\u0430\u0442\u044c \u0434\u0430\u043b\u0435\u0435<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[55],"tags":[],"_links":{"self":[{"href":"http:\/\/studentpmr.ru\/index.php?rest_route=\/wp\/v2\/posts\/7679"}],"collection":[{"href":"http:\/\/studentpmr.ru\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/studentpmr.ru\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/studentpmr.ru\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/studentpmr.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=7679"}],"version-history":[{"count":0,"href":"http:\/\/studentpmr.ru\/index.php?rest_route=\/wp\/v2\/posts\/7679\/revisions"}],"wp:attachment":[{"href":"http:\/\/studentpmr.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7679"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/studentpmr.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7679"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/studentpmr.ru\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7679"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}