A<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://cppe.ru/index.php?action=history&amp;feed=atom&amp;title=C%2B%2B_Tutorial%2FSTL_Introduction%2Fcontainer_as_parameter</id>
		<title>C++ Tutorial/STL Introduction/container as parameter - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://cppe.ru/index.php?action=history&amp;feed=atom&amp;title=C%2B%2B_Tutorial%2FSTL_Introduction%2Fcontainer_as_parameter"/>
		<link rel="alternate" type="text/html" href="http://cppe.ru/index.php?title=C%2B%2B_Tutorial/STL_Introduction/container_as_parameter&amp;action=history"/>
		<updated>2026-04-11T00:51:19Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://cppe.ru/index.php?title=C%2B%2B_Tutorial/STL_Introduction/container_as_parameter&amp;diff=2503&amp;oldid=prev</id>
		<title> в 14:21, 25 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://cppe.ru/index.php?title=C%2B%2B_Tutorial/STL_Introduction/container_as_parameter&amp;diff=2503&amp;oldid=prev"/>
				<updated>2010-05-25T14:21:17Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 14:21, 25 мая 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
			</entry>

	<entry>
		<id>http://cppe.ru/index.php?title=C%2B%2B_Tutorial/STL_Introduction/container_as_parameter&amp;diff=2504&amp;oldid=prev</id>
		<title>Admin: 1 версия:&amp;#32;Импорт контента...</title>
		<link rel="alternate" type="text/html" href="http://cppe.ru/index.php?title=C%2B%2B_Tutorial/STL_Introduction/container_as_parameter&amp;diff=2504&amp;oldid=prev"/>
				<updated>2010-05-25T10:29:52Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия: Импорт контента...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Function with stack as parameter==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
using std::cout;&lt;br /&gt;
using std::endl;&lt;br /&gt;
#include &amp;lt;stack&amp;gt;  // stack adapter definition&lt;br /&gt;
#include &amp;lt;vector&amp;gt; // vector class-template definition&lt;br /&gt;
#include &amp;lt;list&amp;gt;   // list class-template definition&lt;br /&gt;
template&amp;lt; typename T &amp;gt; void pushElements( T &amp;amp;stackRef );&lt;br /&gt;
template&amp;lt; typename T &amp;gt; void popElements( T &amp;amp;stackRef );&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
   std::stack&amp;lt; int &amp;gt; intDequeStack;&lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;Pushing onto intDequeStack: &amp;quot;;&lt;br /&gt;
   pushElements( intDequeStack );&lt;br /&gt;
   cout &amp;lt;&amp;lt; endl &amp;lt;&amp;lt; endl;&lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;Popping from intDequeStack: &amp;quot;;&lt;br /&gt;
   popElements( intDequeStack );&lt;br /&gt;
   cout &amp;lt;&amp;lt; endl;&lt;br /&gt;
   return 0;&lt;br /&gt;
}&lt;br /&gt;
template&amp;lt; typename T &amp;gt; void pushElements( T &amp;amp;stackRef )&lt;br /&gt;
{&lt;br /&gt;
   for ( int i = 0; i &amp;lt; 10; i++ )&lt;br /&gt;
   {&lt;br /&gt;
      stackRef.push( i );&lt;br /&gt;
      cout &amp;lt;&amp;lt; stackRef.top() &amp;lt;&amp;lt; &amp;quot; &amp;quot;;&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
template&amp;lt; typename T &amp;gt; void popElements( T &amp;amp;stackRef )&lt;br /&gt;
{&lt;br /&gt;
   while ( !stackRef.empty() )&lt;br /&gt;
   {&lt;br /&gt;
      cout &amp;lt;&amp;lt; stackRef.top() &amp;lt;&amp;lt; &amp;quot; &amp;quot;;&lt;br /&gt;
      stackRef.pop();&lt;br /&gt;
   }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;Pushing onto intDequeStack: 0 1 2 3 4 5 6 7 8 9&lt;br /&gt;
Popping from intDequeStack: 9 8 7 6 5 4 3 2 1 0&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Function with vector as the parameter==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
using std::cout;&lt;br /&gt;
using std::endl;&lt;br /&gt;
#include &amp;lt;vector&amp;gt;&lt;br /&gt;
using std::vector;&lt;br /&gt;
template &amp;lt; typename T &amp;gt; void printVector( const vector&amp;lt; T &amp;gt; &amp;amp;integers2 );&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
   int array[ 6 ] = { 1, 2, 3, 4, 5, 6 }; // initialize array&lt;br /&gt;
   vector&amp;lt; int &amp;gt; integers; // create vector of ints&lt;br /&gt;
   integers.push_back( 2 );&lt;br /&gt;
   integers.push_back( 3 );&lt;br /&gt;
   integers.push_back( 4 );&lt;br /&gt;
   printVector( integers );&lt;br /&gt;
   cout &amp;lt;&amp;lt; endl;&lt;br /&gt;
   return 0;&lt;br /&gt;
}&lt;br /&gt;
template &amp;lt; typename T &amp;gt; void printVector( const vector&amp;lt; T &amp;gt; &amp;amp;integers2 ){&lt;br /&gt;
   typename vector&amp;lt; T &amp;gt;::const_iterator constIterator;&lt;br /&gt;
   for ( constIterator = integers2.begin();&lt;br /&gt;
      constIterator != integers2.end(); ++constIterator )&lt;br /&gt;
      cout &amp;lt;&amp;lt; *constIterator &amp;lt;&amp;lt; &amp;quot; &amp;quot;;&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;2 3 4&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Use list as the function parameter==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
using std::cout;&lt;br /&gt;
using std::endl;&lt;br /&gt;
#include &amp;lt;list&amp;gt;      // list class-template definition&lt;br /&gt;
#include &amp;lt;algorithm&amp;gt; // copy algorithm&lt;br /&gt;
#include &amp;lt;iterator&amp;gt;  // ostream_iterator&lt;br /&gt;
template &amp;lt; typename T &amp;gt; void printList( const std::list&amp;lt; T &amp;gt; &amp;amp;listRef );&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
   int array[ 4 ] = { 2, 6, 4, 8 };&lt;br /&gt;
   std::list&amp;lt; int &amp;gt; values;      // create list of ints&lt;br /&gt;
   std::list&amp;lt; int &amp;gt; otherValues; // create list of ints&lt;br /&gt;
   // insert items in values&lt;br /&gt;
   values.push_front( 1 );&lt;br /&gt;
   values.push_front( 2 );&lt;br /&gt;
   values.push_back( 4 );&lt;br /&gt;
   values.push_back( 3 );&lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;values contains: &amp;quot;;&lt;br /&gt;
   printList( values );&lt;br /&gt;
   cout &amp;lt;&amp;lt; endl;&lt;br /&gt;
   return 0;&lt;br /&gt;
}&lt;br /&gt;
template &amp;lt; typename T &amp;gt; void printList( const std::list&amp;lt; T &amp;gt; &amp;amp;listRef )&lt;br /&gt;
{&lt;br /&gt;
    std::ostream_iterator&amp;lt; T &amp;gt; output( cout, &amp;quot; &amp;quot; );&lt;br /&gt;
    std::copy( listRef.begin(), listRef.end(), output );&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;values contains: 2 1 4 3&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Using template functions to output array of different types==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
using std::cout;&lt;br /&gt;
using std::endl;&lt;br /&gt;
template&amp;lt; typename T &amp;gt;&lt;br /&gt;
void printArray( const T *array, int count )&lt;br /&gt;
{&lt;br /&gt;
   for ( int i = 0; i &amp;lt; count; i++ )&lt;br /&gt;
      cout &amp;lt;&amp;lt; array[ i ] &amp;lt;&amp;lt; &amp;quot; &amp;quot;;&lt;br /&gt;
   cout &amp;lt;&amp;lt; endl;&lt;br /&gt;
}&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
   const int aCount = 5; &lt;br /&gt;
   const int bCount = 7; &lt;br /&gt;
   const int cCount = 6; &lt;br /&gt;
   int a[ aCount ] = { 1, 2, 3, 4, 5 };&lt;br /&gt;
   double b[ bCount ] = { 1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7 };&lt;br /&gt;
   char c[ cCount ] = &amp;quot;HELLO&amp;quot;;&lt;br /&gt;
   printArray( a, aCount );  &lt;br /&gt;
   printArray( b, bCount );  &lt;br /&gt;
   printArray( c, cCount );  &lt;br /&gt;
   return 0;&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;1 2 3 4 5&lt;br /&gt;
1.1 2.2 3.3 4.4 5.5 6.6 7.7&lt;br /&gt;
H E L L O&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>