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%2FFunction%2FFunction_Parameters</id>
		<title>C++/Function/Function Parameters - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://cppe.ru/index.php?action=history&amp;feed=atom&amp;title=C%2B%2B%2FFunction%2FFunction_Parameters"/>
		<link rel="alternate" type="text/html" href="http://cppe.ru/index.php?title=C%2B%2B/Function/Function_Parameters&amp;action=history"/>
		<updated>2026-04-10T07:57:23Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://cppe.ru/index.php?title=C%2B%2B/Function/Function_Parameters&amp;diff=1567&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/Function/Function_Parameters&amp;diff=1567&amp;oldid=prev"/>
				<updated>2010-05-25T14:21:06Z</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/Function/Function_Parameters&amp;diff=1568&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/Function/Function_Parameters&amp;diff=1568&amp;oldid=prev"/>
				<updated>2010-05-25T10:27:23Z</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;==Demonstrates the use of return values with reference type.==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;lt;string&amp;gt;&lt;br /&gt;
using namespace std;&lt;br /&gt;
                                      &lt;br /&gt;
double&amp;amp; referenceMin( double&amp;amp;, double&amp;amp;);    &lt;br /&gt;
                                      &lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
   double x1 = 3.1,  x2 = x1 + 10.5,  y;&lt;br /&gt;
   y = referenceMin( x1, x2);   &lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;x1 = &amp;quot; &amp;lt;&amp;lt; x1 &amp;lt;&amp;lt; &amp;quot;     &amp;quot;&lt;br /&gt;
        &amp;lt;&amp;lt; &amp;quot;x2 = &amp;quot; &amp;lt;&amp;lt; x2 &amp;lt;&amp;lt; endl;&lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;Minimum: &amp;quot; &amp;lt;&amp;lt; y  &amp;lt;&amp;lt; endl;&lt;br /&gt;
   ++referenceMin( x1, x2);     &lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;x1 = &amp;quot; &amp;lt;&amp;lt; x1 &amp;lt;&amp;lt; &amp;quot;     &amp;quot;      &lt;br /&gt;
        &amp;lt;&amp;lt; &amp;quot;x2 = &amp;quot; &amp;lt;&amp;lt; x2 &amp;lt;&amp;lt; endl;        &lt;br /&gt;
   ++referenceMin( x1, x2);           &lt;br /&gt;
                               &lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;x1 = &amp;quot; &amp;lt;&amp;lt; x1 &amp;lt;&amp;lt; &amp;quot;     &amp;quot;      &lt;br /&gt;
        &amp;lt;&amp;lt; &amp;quot;x2 = &amp;quot; &amp;lt;&amp;lt; x2 &amp;lt;&amp;lt; endl;        &lt;br /&gt;
   referenceMin( x1, x2) = 10.1;       &lt;br /&gt;
                                 &lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;x1 = &amp;quot; &amp;lt;&amp;lt; x1 &amp;lt;&amp;lt; &amp;quot;     &amp;quot;    &lt;br /&gt;
        &amp;lt;&amp;lt; &amp;quot;x2 = &amp;quot; &amp;lt;&amp;lt; x2 &amp;lt;&amp;lt; endl;      &lt;br /&gt;
   referenceMin( x1, x2) += 5.0;      &lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;x1 = &amp;quot; &amp;lt;&amp;lt; x1 &amp;lt;&amp;lt; &amp;quot;     &amp;quot;     &lt;br /&gt;
        &amp;lt;&amp;lt; &amp;quot;x2 = &amp;quot; &amp;lt;&amp;lt; x2 &amp;lt;&amp;lt; endl;       &lt;br /&gt;
   return 0;&lt;br /&gt;
}&lt;br /&gt;
double&amp;amp; referenceMin( double&amp;amp; a, double&amp;amp; b){&lt;br /&gt;
    return a &amp;lt;= b ? a : b;       &lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Expressions with reference type exemplified by string assignments.==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;lt;string&amp;gt;&lt;br /&gt;
#include &amp;lt;cctype&amp;gt;                &lt;br /&gt;
using namespace std;&lt;br /&gt;
void strToUpper( string&amp;amp; );      &lt;br /&gt;
int main(){&lt;br /&gt;
   string text(&amp;quot;Test with assignments \n&amp;quot;);&lt;br /&gt;
   strToUpper(text);&lt;br /&gt;
   cout &amp;lt;&amp;lt; text &amp;lt;&amp;lt; endl;&lt;br /&gt;
   strToUpper( text = &amp;quot;lower case&amp;quot;);&lt;br /&gt;
   cout &amp;lt;&amp;lt; text &amp;lt;&amp;lt; endl;&lt;br /&gt;
   strToUpper( text += &amp;quot; and lower case!\n&amp;quot;);&lt;br /&gt;
   cout &amp;lt;&amp;lt; text &amp;lt;&amp;lt; endl;&lt;br /&gt;
   return 0;&lt;br /&gt;
}&lt;br /&gt;
void strToUpper( string&amp;amp; str){                              &lt;br /&gt;
    int len = str.length();&lt;br /&gt;
    for( int i=0; i &amp;lt; len; ++i)&lt;br /&gt;
      str[i] = toupper( str[i]);&lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Function parameters==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;lt;string&amp;gt;&lt;br /&gt;
using namespace std;&lt;br /&gt;
void printMessage(string, int);  &lt;br /&gt;
int main ()&lt;br /&gt;
{&lt;br /&gt;
   string name;&lt;br /&gt;
   int age; &lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;Enter name: &amp;quot;;&lt;br /&gt;
   cin &amp;gt;&amp;gt; name;&lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;Enter age: &amp;quot;;&lt;br /&gt;
   cin &amp;gt;&amp;gt; age;&lt;br /&gt;
   printMessage(name, age); &lt;br /&gt;
   return 0;&lt;br /&gt;
}&lt;br /&gt;
void printMessage (string theName, int theAge)&lt;br /&gt;
{&lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;Your name is &amp;quot; &amp;lt;&amp;lt; theName &lt;br /&gt;
      &amp;lt;&amp;lt; &amp;quot; and your age is &amp;quot; &amp;lt;&amp;lt; theAge &amp;lt;&amp;lt; endl;&lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Function: reference version and pointer version==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
using namespace std;&lt;br /&gt;
void referenceVersion(int &amp;amp;i); // reference version&lt;br /&gt;
void pointerVersion(int *i); // pointer version&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
  int i = 10;&lt;br /&gt;
  int j = 20;&lt;br /&gt;
  referenceVersion(i);&lt;br /&gt;
  pointerVersion(&amp;amp;j);&lt;br /&gt;
  cout &amp;lt;&amp;lt; i &amp;lt;&amp;lt; &amp;quot; &amp;quot; &amp;lt;&amp;lt; j &amp;lt;&amp;lt; &amp;quot;\n&amp;quot;;&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
// using a reference parameter&lt;br /&gt;
void referenceVersion(int &amp;amp;i)&lt;br /&gt;
{  &lt;br /&gt;
  i = -i;&lt;br /&gt;
}&lt;br /&gt;
// using a pointer parameter&lt;br /&gt;
void pointerVersion(int *i)&lt;br /&gt;
{&lt;br /&gt;
  *i = - *i;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Function uses two arguments==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;lt;string&amp;gt;&lt;br /&gt;
using namespace std;&lt;br /&gt;
void printMessage(string, string);  &lt;br /&gt;
int main ()&lt;br /&gt;
{&lt;br /&gt;
   string name1, name2;&lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;Enter first name: &amp;quot;;&lt;br /&gt;
   cin &amp;gt;&amp;gt; name1;&lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;Enter last name: &amp;quot;;&lt;br /&gt;
   cin &amp;gt;&amp;gt; name2;&lt;br /&gt;
   printMessage(name1, name2); &lt;br /&gt;
   return 0;&lt;br /&gt;
}&lt;br /&gt;
void printMessage (string firstName, string lastName)&lt;br /&gt;
{&lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;Your name is &amp;quot; &amp;lt;&amp;lt; firstName &amp;lt;&amp;lt; &amp;quot; &amp;quot; &amp;lt;&amp;lt; lastName &amp;lt;&amp;lt; endl;&lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Passed by value and passed by reference==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
using namespace std;&lt;br /&gt;
void addNumbers(int, int, int&amp;amp;);  &lt;br /&gt;
int main ()&lt;br /&gt;
{&lt;br /&gt;
   int firstNum, secondNum, sum = 0;&lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;Enter first number: &amp;quot;;&lt;br /&gt;
   cin &amp;gt;&amp;gt; firstNum;&lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;Enter second number: &amp;quot;;&lt;br /&gt;
   cin &amp;gt;&amp;gt; secondNum;&lt;br /&gt;
   addNumbers (firstNum, secondNum, sum);&lt;br /&gt;
   cout &amp;lt;&amp;lt; firstNum &amp;lt;&amp;lt; &amp;quot; + &amp;quot; &amp;lt;&amp;lt; secondNum &amp;lt;&amp;lt; &amp;quot; = &amp;quot; &amp;lt;&amp;lt; sum;&lt;br /&gt;
   return 0;&lt;br /&gt;
}&lt;br /&gt;
void addNumbers (int x, int y, int&amp;amp; z)&lt;br /&gt;
{&lt;br /&gt;
   z = x + y;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Passes the variable to be doubled by reference==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
using namespace std;&lt;br /&gt;
void doubleIt(int&amp;amp;);  &lt;br /&gt;
int main ()&lt;br /&gt;
{&lt;br /&gt;
   int num;&lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;Enter number: &amp;quot;;&lt;br /&gt;
   cin &amp;gt;&amp;gt; num;&lt;br /&gt;
   doubleIt(num);&lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;The number doubled in main is &amp;quot; &amp;lt;&amp;lt; num &amp;lt;&amp;lt; endl;&lt;br /&gt;
   return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void doubleIt (int&amp;amp; x)&lt;br /&gt;
{&lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;The number to be doubled is &amp;quot; &amp;lt;&amp;lt; x &amp;lt;&amp;lt; endl;&lt;br /&gt;
   x *= 2;&lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;The number doubled in doubleIt is &amp;quot; &amp;lt;&amp;lt; x &amp;lt;&amp;lt; endl;&lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Passing Arguments by Reference==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
using namespace std;&lt;br /&gt;
void doubleIt(int);  &lt;br /&gt;
int main ()&lt;br /&gt;
{&lt;br /&gt;
   int num;&lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;Enter number: &amp;quot;;&lt;br /&gt;
   cin &amp;gt;&amp;gt; num;&lt;br /&gt;
   doubleIt(num);&lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;The number doubled in main is &amp;quot; &amp;lt;&amp;lt; num &amp;lt;&amp;lt; endl;&lt;br /&gt;
   return 0;&lt;br /&gt;
}&lt;br /&gt;
void doubleIt (int x)&lt;br /&gt;
{&lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;The number to be doubled is &amp;quot; &amp;lt;&amp;lt; x &amp;lt;&amp;lt; endl;&lt;br /&gt;
   x *= 2;&lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;The number doubled in doubleIt is &amp;quot; &amp;lt;&amp;lt; x &amp;lt;&amp;lt; endl;&lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Passing Arguments by Value==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;lt;string&amp;gt;&lt;br /&gt;
using namespace std;&lt;br /&gt;
void printMessage(string);  &lt;br /&gt;
int main ()&lt;br /&gt;
{&lt;br /&gt;
   string str;&lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;Enter a string: &amp;quot;;&lt;br /&gt;
   cin &amp;gt;&amp;gt; str;&lt;br /&gt;
   printMessage(str); &lt;br /&gt;
   return 0;&lt;br /&gt;
}&lt;br /&gt;
void printMessage (string s)&lt;br /&gt;
{&lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;You inputted &amp;quot; &amp;lt;&amp;lt; s;&lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Pass string (char *) into a function==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;lt;iomanip&amp;gt;&lt;br /&gt;
#include &amp;lt;cstring&amp;gt;&lt;br /&gt;
using namespace std;&lt;br /&gt;
void center(char *s);&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
  center(&amp;quot;www.java2s.com&amp;quot;);&lt;br /&gt;
  center(&amp;quot;www.java2s.com&amp;quot;);&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
void center(char *s)&lt;br /&gt;
{&lt;br /&gt;
  int len;&lt;br /&gt;
  len = 40+(strlen(s)/2);&lt;br /&gt;
  cout &amp;lt;&amp;lt; setw(len) &amp;lt;&amp;lt; s &amp;lt;&amp;lt; &amp;quot;\n&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>