{"id":7516,"date":"2009-04-08T16:15:56","date_gmt":"2009-04-08T13:15:56","guid":{"rendered":"http:\/\/studentpmr.ru\/?p=7516"},"modified":"2009-04-08T16:15:56","modified_gmt":"2009-04-08T13:15:56","slug":"%d1%88%d0%b0%d0%b1%d0%bb%d0%be%d0%bd%d0%bd%d1%8b%d0%b5-%d0%ba%d0%bb%d0%b0%d1%81%d1%81%d1%8b-2","status":"publish","type":"post","link":"https:\/\/studentpmr.ru\/?p=7516","title":{"rendered":"\u0428\u0430\u0431\u043b\u043e\u043d\u043d\u044b\u0435 \u043a\u043b\u0430\u0441\u0441\u044b"},"content":{"rendered":"<p>\u0428\u0430\u0431\u043b\u043e\u043d \u043a\u043b\u0430\u0441\u0441\u0430 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442 \u0441\u043a\u0435\u043b\u0435\u0442 \u043e\u0431\u043e\u0431\u0449\u0435\u043d\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0434\u043b\u044f \u0435\u0433\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0442\u0438\u043f\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c. \u041a\u0430\u043a \u0438 \u0448\u0430\u0431\u043b\u043e\u043d\u044b \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0448\u0430\u0431\u043b\u043e\u043d\u044b \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u043e\u0431\u044b\u0447\u043d\u043e \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0432 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u0447\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u0430\u0445.<\/p>\n<p> <!--more-->  <\/p>\n<p>\/\/ \u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 2<\/p>\n<p>#ifndef _DB<\/p>\n<p>#define _DB<\/p>\n<p>template&lt;class T&gt;<\/p>\n<p>class TDatabase {<\/p>\n<p>private:<\/p>\n<p>T *rp; \/\/\u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u0437\u0430\u043f\u0438\u0441\u0438<\/p>\n<p>int num; \/\/\u0447\u0438\u0441\u043b\u043e \u0437\u0430\u043f\u0438\u0441\u0435\u0439<\/p>\n<p>public:<\/p>\n<p>TDatabase(int n)<\/p>\n<p>{ pr = new T[ num = n];}<\/p>\n<p>~TDatabase() {delete[] rp }<\/p>\n<p>void DoNothing(void);<\/p>\n<p>T &amp;GetRecord(int recnum);<\/p>\n<p>};<\/p>\n<p>template&lt;class T&gt;<\/p>\n<p>void TDatabase&lt;T&gt;::DoNothing(void) { }<\/p>\n<p>template&lt;class T&gt;<\/p>\n<p>T &amp;TDatabase&lt;T&gt;::GetRecord(int recnum)<\/p>\n<p>{<\/p>\n<p>T *crp = rp;<\/p>\n<p>if (0 &lt;= recnum &amp;&amp; recnum &lt; num)<\/p>\n<p>while (recnum &#8212; &gt;0)<\/p>\n<p>crp++;<\/p>\n<p>return *crp;<\/p>\n<p>}<\/p>\n<p>#endif<\/p>\n<p>#include &lt;iostream.h&gt;<\/p>\n<p>#include &lt;string.h&gt;<\/p>\n<p>#include &quot;db.h&quot;<\/p>\n<p>class TRecord {<\/p>\n<p>private:<\/p>\n<p>char name[41];<\/p>\n<p>public:<\/p>\n<p>TRecord() { name[0] = 0; }<\/p>\n<p>TRecord(const char *s) { Assign(s); }<\/p>\n<p>void Assign(const char *s) { strcpy(name, s); }<\/p>\n<p>char *GetName(void) { return name; }<\/p>\n<p>};<\/p>\n<p>void main()<\/p>\n<p>{<\/p>\n<p>int rn; \/\/\u0438\u043d\u0434\u0435\u043a\u0441 \u0447\u0438\u0441\u043b\u0430 \u0437\u0430\u043f\u0438\u0441\u0435\u0439<\/p>\n<p>TDatabase&lt;TRecord&gt; db(3); \/\/\u0431\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u0442\u0440\u0435\u0445 \u0437\u0430\u043f\u0438\u0441\u0435\u0439<\/p>\n<p>TDatabase&lt;TRecord*&gt; dbp(3); \/\/\u0431\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u0442\u0440\u0435\u0445 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u0439<\/p>\n<p>TDatabase&lt;TRecord&gt; *pdb; \/\/\u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u0411\u0414<\/p>\n<p>TDatabase&lt;TRecord*&gt; *ppdb; \/\/\u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u0411\u0414 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u0439<\/p>\n<p>cout &lt;&lt; endl &lt;&lt; &quot;Database of 3 TRecord&quot; &lt;&lt; endl;<\/p>\n<p>db.GetRecord(0).Assign(&quot;George Washington&quot;);<\/p>\n<p>db.GetRecord(1).Assign(&quot;John Adams&quot;);<\/p>\n<p>db.GetRecord(2).Assign(&quot;Thomas Jefferson&quot;);<\/p>\n<p>for ( rn = 0; rn &lt; 3; rn++ )<\/p>\n<p>cout &lt;&lt; db.GetRecord(rn).GetName() &lt;&lt; endl;<\/p>\n<p>cout &lt;&lt; endl &lt;&lt; &quot;Database of 3 TRecord pointers&quot; &lt;&lt; endl;<\/p>\n<p>dbp.GetRecord(0) = new TRecord(&quot;George Washington&quot;);<\/p>\n<p>dbp.GetRecord(1) = new TRecord(&quot;John Adams&quot;);<\/p>\n<p>dbp.GetRecord(2) = new TRecord(&quot;Thomas Jefferson&quot;);<\/p>\n<p>for ( rn = 0; rn &lt; 3; rn++ )<\/p>\n<p>cout &lt;&lt; dbp.GetRecord(rn)-&gt;GetName() &lt;&lt; endl;<\/p>\n<p>cout &lt;&lt; endl &lt;&lt; &quot;Pointer to database of 3 TRecord &quot; &lt;&lt; endl;<\/p>\n<p>pdb= new TDatabase&lt;TRecord&gt;(3);<\/p>\n<p>pdb-&gt;GetRecord(0).Assign(&quot;George Washington&quot;);<\/p>\n<p>pdb-&gt;GetRecord(1).Assign(&quot;John Adams&quot;);<\/p>\n<p>pdb-&gt;GetRecord(2).Assign(&quot;Thomas Jefferson&quot;);<\/p>\n<p>for ( rn = 0; rn &lt; 3; rn++ )<\/p>\n<p>cout &lt;&lt; pdb-&gt;GetRecord(rn).GetName() &lt;&lt; endl;<\/p>\n<p>cout &lt;&lt; endl &lt;&lt; &quot;Pointer to database of 3 TRecord pointers&quot; &lt;&lt; endl;<\/p>\n<p>ppdb = new TDatabase&lt;TRecord *&gt;(3);<\/p>\n<p>ppdb-&gt;GetRecord(0) = new TRecord(&quot;George Washington&quot;);<\/p>\n<p>ppdb-&gt;GetRecord(1) = new TRecord(&quot;John Adams&quot;);<\/p>\n<p>ppdb-&gt;GetRecord(2) = new TRecord(&quot;Thomas Jefferson&quot;);<\/p>\n<p>for ( rn = 0; rn &lt; 3; rn++ )<\/p>\n<p>cout &lt;&lt; ppdb-&gt;GetRecord(rn)-&gt;GetName() &lt;&lt; endl;<\/p>\n<p>}<\/p>\n<p>\u041c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u0434\u0440\u0443\u0433\u0438\u0445 \u0442\u0438\u043f\u043e\u0432 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439, \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0430\u043a\u0438\u0435 \u0442\u0438\u043f\u044b \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u043a\u0430\u043a TRecord.<\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440: TDatabase&lt;double&gt; dbd(100);<\/p>\n<p>\u041d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0448\u0438\u0440\u043e\u043a\u043e\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0448\u0430\u0431\u043b\u043e\u043d\u044b \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u043d\u0430\u0445\u043e\u0434\u044f\u0442 \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432. \u041a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043d\u044b\u043c\u0438 \u043a\u043b\u0430\u0441\u0441\u0430\u043c\u0438 \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043a\u043b\u0430\u0441\u0441\u044b, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043c\u0430\u0441\u0441\u0438\u0432\u044b, \u0441\u0432\u044f\u0437\u043d\u044b\u0435 \u0441\u043f\u0438\u0441\u043a\u0438.<\/p>\n<p>\u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0442\u0438\u043f\u044b \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u0432:<\/p>\n<p>&#8212; \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043d\u044b\u0439 (&quot;\u0437\u0430\u0449\u0438\u0449\u0435\u043d\u043d\u044b\u0439&quot;) \u043c\u0430\u0441\u0441\u0438\u0432<\/p>\n<p>&#8212; \u043e\u0447\u0435\u0440\u0435\u0434\u044c<\/p>\n<p>&#8212; \u0441\u0442\u0435\u043a<\/p>\n<p>&#8212; \u0441\u0432\u044f\u0437\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a<\/p>\n<p>&#8212; \u0431\u0438\u043d\u0430\u0440\u043d\u043e\u0435 \u0434\u0435\u0440\u0435\u0432\u043e<\/p>\n<p>\u041a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u0432 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0438 \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u044f \u043d\u0430\u0434 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0435\u0439 \u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u043c\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u043c\u0438.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0428\u0430\u0431\u043b\u043e\u043d \u043a\u043b\u0430\u0441\u0441\u0430 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442 \u0441\u043a\u0435\u043b\u0435\u0442 \u043e\u0431\u043e\u0431\u0449\u0435\u043d\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0434\u043b\u044f \u0435\u0433\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0442\u0438\u043f\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c. \u041a\u0430\u043a \u0438 \u0448\u0430\u0431\u043b\u043e\u043d\u044b \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0448\u0430\u0431\u043b\u043e\u043d\u044b \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u043e\u0431\u044b\u0447\u043d\u043e \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0432 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u0447\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u0430\u0445.<\/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":"https:\/\/studentpmr.ru\/index.php?rest_route=\/wp\/v2\/posts\/7516"}],"collection":[{"href":"https:\/\/studentpmr.ru\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/studentpmr.ru\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/studentpmr.ru\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/studentpmr.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=7516"}],"version-history":[{"count":0,"href":"https:\/\/studentpmr.ru\/index.php?rest_route=\/wp\/v2\/posts\/7516\/revisions"}],"wp:attachment":[{"href":"https:\/\/studentpmr.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7516"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/studentpmr.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7516"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/studentpmr.ru\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7516"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}