<?xml version='1.0' encoding="utf-8"?>
      <rss version='2.0'>
      <channel>
      <title>Форум на Исходниках.RU</title>
      <link>https://forum.sources.ru</link>
      <description>Форум на Исходниках.RU</description>
      <generator>Форум на Исходниках.RU</generator>
  	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=141400&amp;view=findpost&amp;p=1094140</guid>
        <pubDate>Sun, 07 May 2006 18:10:58 +0000</pubDate>
        <title>Отличие iostream от iostream.h ???</title>
        <link>https://forum.sources.ru/index.php?showtopic=141400&amp;view=findpost&amp;p=1094140</link>
        <description><![CDATA[Druid: Так пример из Страуструпа и есть :)<br><br>Спасибо всем за помощь )]]></description>
        <author>Druid</author>
        <category>C/C++: Общие вопросы</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=141400&amp;view=findpost&amp;p=1094126</guid>
        <pubDate>Sun, 07 May 2006 17:26:55 +0000</pubDate>
        <title>Отличие iostream от iostream.h ???</title>
        <link>https://forum.sources.ru/index.php?showtopic=141400&amp;view=findpost&amp;p=1094126</link>
        <description><![CDATA[Neko: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=141400&view=findpost&p=1094125'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>Druid &#064; <time class="tag-quote__quoted-time" datetime="2006-05-07T17:23:47+00:00">07.05.06, 17:23</time></span><div class='quote '>то есть пространство имен указывается один раз при вызове кноструктора, а потом к объекту можно обращаться как обычно?</div></div><br>
следи за определениями:<br>
 в какой области объявлен класс A? В my, значит пишем my::A<br>
 в какой области объявлен объект a? В общей, значит пишем a<br>
<br>
Советую почитать Страуструпа]]></description>
        <author>Neko</author>
        <category>C/C++: Общие вопросы</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=141400&amp;view=findpost&amp;p=1094125</guid>
        <pubDate>Sun, 07 May 2006 17:23:47 +0000</pubDate>
        <title>Отличие iostream от iostream.h ???</title>
        <link>https://forum.sources.ru/index.php?showtopic=141400&amp;view=findpost&amp;p=1094125</link>
        <description><![CDATA[Druid: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=141400&view=findpost&p=1093902'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>kalexs_uzb &#064; <time class="tag-quote__quoted-time" datetime="2006-05-07T08:40:26+00:00">07.05.06, 08:40</time></span><div class='quote '>&lt;имя объект&gt;-&gt;&lt;имя функции&gt; или &lt;имя объект&gt;.&lt;имя функции&gt;.<br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">my::A a;</div><div class="code_line">a.f();</div></ol></div></div></div></div><script>preloadCodeButtons('1');</script></div></div><br>
то есть пространство имен указывается один раз при вызове кноструктора, а потом к объекту можно обращаться как обычно?]]></description>
        <author>Druid</author>
        <category>C/C++: Общие вопросы</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=141400&amp;view=findpost&amp;p=1094009</guid>
        <pubDate>Sun, 07 May 2006 12:05:35 +0000</pubDate>
        <title>Отличие iostream от iostream.h ???</title>
        <link>https://forum.sources.ru/index.php?showtopic=141400&amp;view=findpost&amp;p=1094009</link>
        <description><![CDATA[Dmitrys: <div class='tag-quote'><span class='tag-quote-prefix'>Цитата</span> <div class='quote '>Переименовал класс и все с ним связанное из string в string_my ошибки уменьшились. Поместил новый класс string_my в новое пространство имен my и ошибки исчезли совсем.</div></div><br>
<br>
Если не ошибаюсь, просто в &lt;iostream&gt; уже есть свой класс string]]></description>
        <author>Dmitrys</author>
        <category>C/C++: Общие вопросы</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=141400&amp;view=findpost&amp;p=1093935</guid>
        <pubDate>Sun, 07 May 2006 09:40:54 +0000</pubDate>
        <title>Отличие iostream от iostream.h ???</title>
        <link>https://forum.sources.ru/index.php?showtopic=141400&amp;view=findpost&amp;p=1093935</link>
        <description><![CDATA[Druid: Есть еще вопрос не по созданной теме, но по приведенному примеру.<br>Когда операторную функцию нужно определять как функцию-член, а когда как глобальную с описанием Friend ???]]></description>
        <author>Druid</author>
        <category>C/C++: Общие вопросы</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=141400&amp;view=findpost&amp;p=1093902</guid>
        <pubDate>Sun, 07 May 2006 08:40:26 +0000</pubDate>
        <title>Отличие iostream от iostream.h ???</title>
        <link>https://forum.sources.ru/index.php?showtopic=141400&amp;view=findpost&amp;p=1093902</link>
        <description><![CDATA[kalexs_uzb: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=141400&view=findpost&p=1093896'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>Druid &#064; <time class="tag-quote__quoted-time" datetime="2006-05-07T08:19:46+00:00">07.05.06, 08:19</time></span><div class='quote '>А как теперь обращаться к функциям-членам из функции main()?</div></div><br>
&lt;имя объект&gt;-&gt;&lt;имя функции&gt; или &lt;имя объект&gt;.&lt;имя функции&gt;.<br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">my::A a;</div><div class="code_line">a.f();</div></ol></div></div></div></div>]]></description>
        <author>kalexs_uzb</author>
        <category>C/C++: Общие вопросы</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=141400&amp;view=findpost&amp;p=1093896</guid>
        <pubDate>Sun, 07 May 2006 08:19:46 +0000</pubDate>
        <title>Отличие iostream от iostream.h ???</title>
        <link>https://forum.sources.ru/index.php?showtopic=141400&amp;view=findpost&amp;p=1093896</link>
        <description><![CDATA[Druid: Переименовал класс и все с ним связанное из string в string_my ошибки уменьшились. Поместил новый класс string_my в новое пространство имен my и ошибки исчезли совсем.<br>
<br>
А как теперь обращаться к функциям-членам из функции main()<br>
<br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">my::string_my::&#60;нужная функция&#62;</div></ol></div></div></div></div><br>
?<br>
Указывать сперва пространство, потом имя класса, если их несколько в моем пространстве имен, а потом нужную мне функцию?]]></description>
        <author>Druid</author>
        <category>C/C++: Общие вопросы</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=141400&amp;view=findpost&amp;p=1093856</guid>
        <pubDate>Sun, 07 May 2006 06:04:21 +0000</pubDate>
        <title>Отличие iostream от iostream.h ???</title>
        <link>https://forum.sources.ru/index.php?showtopic=141400&amp;view=findpost&amp;p=1093856</link>
        <description><![CDATA[trainer: Чтобы не потревожить внутренности, надо создавать свое пространство имен(namespace)]]></description>
        <author>trainer</author>
        <category>C/C++: Общие вопросы</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=141400&amp;view=findpost&amp;p=1093707</guid>
        <pubDate>Sat, 06 May 2006 19:20:35 +0000</pubDate>
        <title>Отличие iostream от iostream.h ???</title>
        <link>https://forum.sources.ru/index.php?showtopic=141400&amp;view=findpost&amp;p=1093707</link>
        <description><![CDATA[Neko: &lt;iostream&gt; - это по новому стандарту. Раньше было &lt;iostream.h&gt;<br><br>Что касается using-определений, рекомендуется подключать только необходимые в проекте классы/функции, чтобы не потревожить внутренности STL. Что ты и сделал, переопрелив стандартный класс string  :wacko:]]></description>
        <author>Neko</author>
        <category>C/C++: Общие вопросы</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=141400&amp;view=findpost&amp;p=1093209</guid>
        <pubDate>Sat, 06 May 2006 08:45:23 +0000</pubDate>
        <title>Отличие iostream от iostream.h ???</title>
        <link>https://forum.sources.ru/index.php?showtopic=141400&amp;view=findpost&amp;p=1093209</link>
        <description><![CDATA[mo3r: 1. К чему тут объявлен класс string?<br>
2. В данном примере, если хочется оставить свой класс string, можно внести его в свое простанство имен:<br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">#include &#60;iostream&#62;</div><div class="code_line">#include &#60;string.h&#62;</div><div class="code_line">#include &#60;stdlib.h&#62;</div><div class="code_line">&nbsp;</div><div class="code_line">using namespace std;</div><div class="code_line">&nbsp;</div><div class="code_line">namespace my{</div><div class="code_line">&nbsp;</div><div class="code_line">class string {</div><div class="code_line">&nbsp;&nbsp; &nbsp;struct srep {</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;char* s;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;int n; //счетчик числа ссылок</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;srep() {n = 1;}</div><div class="code_line">&nbsp;&nbsp; &nbsp;};</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;srep* p;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;public:</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;string(const char*);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;string();</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;string(const string &amp;);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;string&amp; operator =(const char *);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;string&amp; operator =(const string &amp;);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;~string();</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;char &amp; operator [](int i);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;friend ostream&amp; operator &#60;&#60;(ostream&amp;, const string&amp;);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;friend istream&amp; operator &#62;&#62;(istream&amp;, string&amp;);</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;friend int operator ==(const string &amp; x, const char* s)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;{ return 0 == strcmp(x.p-&#62;s,s); }</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;friend int operator ==(const string &amp; x, const string &amp; y)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;{ return 0 == strcmp(x.p-&#62;s,y.p-&#62;s); }</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;friend int operator !=(const string &amp; x, const char* s)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;{ return 0 != strcmp(x.p-&#62;s,s); }</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;friend int operator !=(const string &amp; x, const string &amp; y)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;{ return 0 != strcmp(x.p-&#62;s,y.p-&#62;s); }</div><div class="code_line">};</div><div class="code_line">....</div><div class="code_line">}</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;</div><div class="code_line">void error(const char* p)</div><div class="code_line">{</div><div class="code_line">&nbsp;&nbsp; &nbsp;cerr &#60;&#60; p &#60;&#60; &quot;\n&quot;;</div><div class="code_line">&nbsp;&nbsp; &nbsp;exit(1);</div><div class="code_line">}</div><div class="code_line">&nbsp;</div><div class="code_line">int main()</div><div class="code_line">{</div><div class="code_line">&nbsp;&nbsp; &nbsp;my::string x[100];</div><div class="code_line">&nbsp;&nbsp; &nbsp;int n;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;cout &#60;&#60; &quot;здесь начало\n&quot;;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;for(n=0; cin&#62;&#62;x[n]; n++) {</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if (100 == n) {</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;error(&quot;слишком много слов&quot;);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return 99;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;my::string y;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;cout &#60;&#60; (y = x[n]);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if (y == &quot;doun&quot;) break;</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;cout &#60;&#60; &quot;теперь мы идем по словам в обратном порядке \n&quot;;</div><div class="code_line">&nbsp;&nbsp; &nbsp;for(int i=n-1; 0&#60;=i; i--) cout &#60;&#60; x[i];</div><div class="code_line">&nbsp;&nbsp; &nbsp;return 0;</div><div class="code_line">}</div></ol></div></div></div></div>]]></description>
        <author>mo3r</author>
        <category>C/C++: Общие вопросы</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=141400&amp;view=findpost&amp;p=1093121</guid>
        <pubDate>Sat, 06 May 2006 07:42:30 +0000</pubDate>
        <title>Отличие iostream от iostream.h ???</title>
        <link>https://forum.sources.ru/index.php?showtopic=141400&amp;view=findpost&amp;p=1093121</link>
        <description><![CDATA[Druid: Спасибо за ссылки, сейчас почитаю...]]></description>
        <author>Druid</author>
        <category>C/C++: Общие вопросы</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=141400&amp;view=findpost&amp;p=1093117</guid>
        <pubDate>Sat, 06 May 2006 07:41:05 +0000</pubDate>
        <title>Отличие iostream от iostream.h ???</title>
        <link>https://forum.sources.ru/index.php?showtopic=141400&amp;view=findpost&amp;p=1093117</link>
        <description><![CDATA[Hryak: Тема много раз обсасывалась:<br>
<a class='tag-url' href='http://forum.sources.ru/index.php?showtopic=123519' target='_blank'>Глюки using namespace std</a><br>
<a class='tag-url' href='http://forum.sources.ru/index.php?showtopic=131180' target='_blank'>Функция друг</a><br>
<a class='tag-url' href='http://forum.sources.ru/index.php?showtopic=120149' target='_blank'>Друзья</a>]]></description>
        <author>Hryak</author>
        <category>C/C++: Общие вопросы</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=141400&amp;view=findpost&amp;p=1093111</guid>
        <pubDate>Sat, 06 May 2006 07:35:22 +0000</pubDate>
        <title>Отличие iostream от iostream.h ???</title>
        <link>https://forum.sources.ru/index.php?showtopic=141400&amp;view=findpost&amp;p=1093111</link>
        <description><![CDATA[Druid: error C2872: &#39;string&#39; : ambiguous symbol<br>error C2872: &#39;string&#39; : ambiguous symbol<br>error C2872: &#39;string&#39; : ambiguous symbol<br>error C2248: &#39;p&#39; : cannot access private member declared in class &#39;string&#39;<br>see declaration of &#39;p&#39;<br>error C2248: &#39;p&#39; : cannot access private member declared in class &#39;string&#39;<br>see declaration of &#39;p&#39;<br>error C2872: &#39;string&#39; : ambiguous symbol<br>error C2593: &#39;operator &lt;&lt;&#39; is ambiguous<br>error C2872: &#39;string&#39; : ambiguous symbol<br>error C2593: &#39;operator &gt;&gt;&#39; is ambiguous<br>error C2872: &#39;string&#39; : ambiguous symbol<br>error C2593: &#39;operator &lt;&lt;&#39; is ambiguous<br>error C2593: &#39;operator &lt;&lt;&#39; is ambiguous<br>Error executing cl.exe.<br><br>main1.obj - 12 error(s), 0 warning(s)<br><br>Ошибки почти везде где есть перегрузка операций]]></description>
        <author>Druid</author>
        <category>C/C++: Общие вопросы</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=141400&amp;view=findpost&amp;p=1093092</guid>
        <pubDate>Sat, 06 May 2006 07:15:10 +0000</pubDate>
        <title>Отличие iostream от iostream.h ???</title>
        <link>https://forum.sources.ru/index.php?showtopic=141400&amp;view=findpost&amp;p=1093092</link>
        <description><![CDATA[Flex Ferrum: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=141400&view=findpost&p=1093078'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>Druid &#064; <time class="tag-quote__quoted-time" datetime="2006-05-06T07:10:49+00:00">06.05.06, 07:10</time></span><div class='quote '>Он при смене библиотеки начинает придираться к перегрузке операций почему-то... </div></div><br>
В таком случае ошибки и код в студию.]]></description>
        <author>Flex Ferrum</author>
        <category>C/C++: Общие вопросы</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=141400&amp;view=findpost&amp;p=1093078</guid>
        <pubDate>Sat, 06 May 2006 07:10:49 +0000</pubDate>
        <title>Отличие iostream от iostream.h ???</title>
        <link>https://forum.sources.ru/index.php?showtopic=141400&amp;view=findpost&amp;p=1093078</link>
        <description><![CDATA[Druid: Так в примере при замене библиотеки с &lt;iostream.h&gt; на &lt;iostream&gt; еще и прописывается строка<br>
<br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">using namespace std;</div></ol></div></div></div></div><br>
<br>
Без нее компилятор выдает вообще 42 ошибки ))<br>
Он при смене библиотеки начинает придираться к перегрузке операций почему-то...]]></description>
        <author>Druid</author>
        <category>C/C++: Общие вопросы</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=141400&amp;view=findpost&amp;p=1093043</guid>
        <pubDate>Sat, 06 May 2006 06:41:10 +0000</pubDate>
        <title>Отличие iostream от iostream.h ???</title>
        <link>https://forum.sources.ru/index.php?showtopic=141400&amp;view=findpost&amp;p=1093043</link>
        <description><![CDATA[Sazabis: А какой у тебя компилятор ? похоже борланд, так он в &lt;iostream.h&gt; делает include stlport&#092;iostream и потом using namespace std;<br>
<br>
<div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=141400&view=findpost&p=1093031'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>Flex Ferrum &#064; <time class="tag-quote__quoted-time" datetime="2006-05-06T07:10:38+00:00">06.05.06, 07:10</time></span><div class='quote '>В iostream.h все классы объявлены в глобальном пространстве имен,</div></div> :no: , там просто include]]></description>
        <author>Sazabis</author>
        <category>C/C++: Общие вопросы</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=141400&amp;view=findpost&amp;p=1093031</guid>
        <pubDate>Sat, 06 May 2006 07:10:38 +0000</pubDate>
        <title>Отличие iostream от iostream.h ???</title>
        <link>https://forum.sources.ru/index.php?showtopic=141400&amp;view=findpost&amp;p=1093031</link>
        <description><![CDATA[Flex Ferrum: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=141400&view=findpost&p=1093018'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>Druid &#064; <time class="tag-quote__quoted-time" datetime="2006-05-06T06:58:21+00:00">06.05.06, 06:58</time></span><div class='quote '>Почему не хочет никак не пойму, я думал эти библиотеки практически одинаковые, только iosrteam стандартизована...</div></div><br>
В iostream.h все классы объявлены в глобальном пространстве имен, а в iostream - в пространстве std. По этому при использовании iostream тебе надо либо в начале файла указать &#092;<br>
using namespace std;<br>
<br>
либо перед каждым упоминанием имени из iostream ставить std::]]></description>
        <author>Flex Ferrum</author>
        <category>C/C++: Общие вопросы</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=141400&amp;view=findpost&amp;p=1093029</guid>
        <pubDate>Sat, 06 May 2006 07:09:03 +0000</pubDate>
        <title>Отличие iostream от iostream.h ???</title>
        <link>https://forum.sources.ru/index.php?showtopic=141400&amp;view=findpost&amp;p=1093029</link>
        <description><![CDATA[SOLON7: Кажется в iostream.h по умолчанию используется пространство имен std.<br>Если не прав поправьте..]]></description>
        <author>SOLON7</author>
        <category>C/C++: Общие вопросы</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=141400&amp;view=findpost&amp;p=1093018</guid>
        <pubDate>Sat, 06 May 2006 06:58:21 +0000</pubDate>
        <title>Отличие iostream от iostream.h ???</title>
        <link>https://forum.sources.ru/index.php?showtopic=141400&amp;view=findpost&amp;p=1093018</link>
        <description><![CDATA[Druid: Доброго времени суток. я тут в процессе обучения реализовал пример из Страуструпа и наткнулся на проблему, пример работает только при подключенной строке<br>
<br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">#include &#60;iostream.h&#62;</div></ol></div></div></div></div><br>
<br>
а при <br>
<br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">#include &#60;iostream&#62;</div></ol></div></div></div></div><br>
не хочет работать ((<br>
<br>
Почему не хочет никак не пойму, я думал эти библиотеки практически одинаковые, только iosrteam стандартизована...<br>
<br>
Вот код программы, реализован под Visual C++ 6.0:<br>
<br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">#include &#60;iostream&#62;</div><div class="code_line">#include &#60;string.h&#62;</div><div class="code_line">#include &#60;stdlib.h&#62;</div><div class="code_line">&nbsp;</div><div class="code_line">using namespace std;</div><div class="code_line">&nbsp;</div><div class="code_line">class string {</div><div class="code_line">&nbsp;&nbsp; &nbsp;struct srep {</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;char* s;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;int n; //счетчик числа ссылок</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;srep() {n = 1;}</div><div class="code_line">&nbsp;&nbsp; &nbsp;};</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;srep* p;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;public:</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;string(const char*);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;string();</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;string(const string &amp;);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;string&amp; operator =(const char *);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;string&amp; operator =(const string &amp;);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;~string();</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;char &amp; operator [](int i);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;friend ostream&amp; operator &#60;&#60;(ostream&amp;, const string&amp;);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;friend istream&amp; operator &#62;&#62;(istream&amp;, string&amp;);</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;friend int operator ==(const string &amp; x, const char* s)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;{ return 0 == strcmp(x.p-&#62;s,s); }</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;friend int operator ==(const string &amp; x, const string &amp; y)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;{ return 0 == strcmp(x.p-&#62;s,y.p-&#62;s); }</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;friend int operator !=(const string &amp; x, const char* s)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;{ return 0 != strcmp(x.p-&#62;s,s); }</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;friend int operator !=(const string &amp; x, const string &amp; y)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;{ return 0 != strcmp(x.p-&#62;s,y.p-&#62;s); }</div><div class="code_line">};</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;</div><div class="code_line">string::string()</div><div class="code_line">{</div><div class="code_line">&nbsp;&nbsp; &nbsp;p = new srep;</div><div class="code_line">&nbsp;&nbsp; &nbsp;p-&#62;s = 0;</div><div class="code_line">}</div><div class="code_line">&nbsp;</div><div class="code_line">string::string(const string&amp; x)</div><div class="code_line">{</div><div class="code_line">&nbsp;&nbsp; &nbsp;x.p-&#62;n++;</div><div class="code_line">&nbsp;&nbsp; &nbsp;p = x.p;</div><div class="code_line">}</div><div class="code_line">&nbsp;</div><div class="code_line">string::string(const char* s)</div><div class="code_line">{</div><div class="code_line">&nbsp;&nbsp; &nbsp;p = new srep;</div><div class="code_line">&nbsp;&nbsp; &nbsp;p-&#62;s = new char[strlen(s) + 1];</div><div class="code_line">&nbsp;&nbsp; &nbsp;strcpy(p-&#62;s,s);</div><div class="code_line">}</div><div class="code_line">&nbsp;</div><div class="code_line">string::~string()</div><div class="code_line">{</div><div class="code_line">&nbsp;&nbsp; &nbsp;if (0 == --p-&#62;n) {</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;delete[] p-&#62;s;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;delete p;</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div><div class="code_line">}</div><div class="code_line">&nbsp;</div><div class="code_line">string&amp; string::operator =(const char* s)</div><div class="code_line">{</div><div class="code_line">&nbsp;&nbsp; &nbsp;if (p-&#62;n &#62; 1) { // отсоединяемся от старой строки</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;p-&#62;n--;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;p = new srep;</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp; &nbsp;else // освобождаем строку со старым значением</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;delete p-&#62;s;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;p-&#62;s = new char[strlen(s) + 1];</div><div class="code_line">&nbsp;&nbsp; &nbsp;strcpy(p-&#62;s,s);</div><div class="code_line">&nbsp;&nbsp; &nbsp;return *this;</div><div class="code_line">}</div><div class="code_line">&nbsp;</div><div class="code_line">string&amp; string::operator =(const string&amp; x)</div><div class="code_line">{</div><div class="code_line">&nbsp;&nbsp; &nbsp;x.p-&#62;n++; // защита от случая &quot;st = st&quot;</div><div class="code_line">&nbsp;&nbsp; &nbsp;if (0 == --p-&#62;n) {</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;delete[] p-&#62;s;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;delete p;</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;p = x.p;</div><div class="code_line">&nbsp;&nbsp; &nbsp;return *this;</div><div class="code_line">}</div><div class="code_line">&nbsp;</div><div class="code_line">ostream&amp; operator &#60;&#60;(ostream&amp; s, const string&amp; x)</div><div class="code_line">{</div><div class="code_line">&nbsp;&nbsp; &nbsp;return s &#60;&#60; x.p-&#62;s &#60;&#60; &quot;[&quot; &#60;&#60; x.p-&#62;n &#60;&#60; &quot;]\n&quot;;</div><div class="code_line">}</div><div class="code_line">&nbsp;</div><div class="code_line">istream&amp; operator &#62;&#62;(istream&amp; s, string&amp; x)</div><div class="code_line">{</div><div class="code_line">&nbsp;&nbsp; &nbsp;char buf[256];</div><div class="code_line">&nbsp;&nbsp; &nbsp;s &#62;&#62; buf; // ненадежно, возможно переполнение buf</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// см. 10,3</div><div class="code_line">&nbsp;&nbsp; &nbsp;x = buf;</div><div class="code_line">&nbsp;&nbsp; &nbsp;cout &#60;&#60; &quot;echo: &quot; &#60;&#60; x &#60;&#60; &quot;\n&quot;;</div><div class="code_line">&nbsp;&nbsp; &nbsp;return s;</div><div class="code_line">}</div><div class="code_line">&nbsp;</div><div class="code_line">void error(const char* p)</div><div class="code_line">{</div><div class="code_line">&nbsp;&nbsp; &nbsp;cerr &#60;&#60; p &#60;&#60; &quot;\n&quot;;</div><div class="code_line">&nbsp;&nbsp; &nbsp;exit(1);</div><div class="code_line">}</div><div class="code_line">&nbsp;</div><div class="code_line">char&amp; string::operator [](int i)</div><div class="code_line">{</div><div class="code_line">&nbsp;&nbsp; &nbsp;if (i&#60;0 || strlen(p-&#62;s)&#60;i) error(&quot;недопустимое значение индекса&quot;);</div><div class="code_line">&nbsp;&nbsp; &nbsp;return p-&#62;s[i];</div><div class="code_line">}</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;</div><div class="code_line">int main()</div><div class="code_line">{</div><div class="code_line">&nbsp;&nbsp; &nbsp;string x[100];</div><div class="code_line">&nbsp;&nbsp; &nbsp;int n;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;cout &#60;&#60; &quot;здесь начало\n&quot;;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;for(n=0; cin&#62;&#62;x[n]; n++) {</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if (100 == n) {</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;error(&quot;слишком много слов&quot;);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return 99;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;string y;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;cout &#60;&#60; (y = x[n]);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if (y == &quot;doun&quot;) break;</div><div class="code_line">&nbsp;&nbsp; &nbsp;}</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;cout &#60;&#60; &quot;теперь мы идем по словам в обратном порядке \n&quot;;</div><div class="code_line">&nbsp;&nbsp; &nbsp;for(int i=n-1; 0&#60;=i; i--) cout &#60;&#60; x[i];</div><div class="code_line">&nbsp;&nbsp; &nbsp;return 0;</div><div class="code_line">}</div></ol></div></div></div></div>]]></description>
        <author>Druid</author>
        <category>C/C++: Общие вопросы</category>
      </item>
	
      </channel>
      </rss>
	