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%2FFunction%2Ffunction_definition</id>
		<title>C++ Tutorial/Function/function definition - История изменений</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%2FFunction%2Ffunction_definition"/>
		<link rel="alternate" type="text/html" href="http://cppe.ru/index.php?title=C%2B%2B_Tutorial/Function/function_definition&amp;action=history"/>
		<updated>2026-04-11T00:50:24Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://cppe.ru/index.php?title=C%2B%2B_Tutorial/Function/function_definition&amp;diff=2477&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/Function/function_definition&amp;diff=2477&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/Function/function_definition&amp;diff=2478&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/Function/function_definition&amp;diff=2478&amp;oldid=prev"/>
				<updated>2010-05-25T10:29:48Z</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;==Compare pass-by-value and pass-by-reference with references==&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;
int byValue( int ); &lt;br /&gt;
void byReference( int &amp;amp; ); &lt;br /&gt;
                                                   &lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
   int x = 2; &lt;br /&gt;
   int z = 4; &lt;br /&gt;
   cout &amp;lt;&amp;lt; byValue( x ) &amp;lt;&amp;lt; endl;  &lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;x = &amp;quot; &amp;lt;&amp;lt; x &amp;lt;&amp;lt; endl;&lt;br /&gt;
   byReference( z );&lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;z = &amp;quot; &amp;lt;&amp;lt; z &amp;lt;&amp;lt; endl;&lt;br /&gt;
   return 0;&lt;br /&gt;
} &lt;br /&gt;
int byValue( int number )&lt;br /&gt;
{&lt;br /&gt;
   return number *= number;&lt;br /&gt;
}&lt;br /&gt;
void byReference( int &amp;amp;numberRef )&lt;br /&gt;
{&lt;br /&gt;
   numberRef *= numberRef; &lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;4&lt;br /&gt;
x = 2&lt;br /&gt;
z = 16&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Default arguments with parameters==&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;
int f( int length = 1, int width = 1, int height = 1 );&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
   cout &amp;lt;&amp;lt; f();&lt;br /&gt;
   &lt;br /&gt;
   cout &amp;lt;&amp;lt; f( 10 );&lt;br /&gt;
        &lt;br /&gt;
   cout &amp;lt;&amp;lt; f( 10, 5 );&lt;br /&gt;
   &lt;br /&gt;
   cout &amp;lt;&amp;lt; f( 10, 5, 2 ) &amp;lt;&amp;lt; endl;&lt;br /&gt;
   return 0;&lt;br /&gt;
} &lt;br /&gt;
int f( int length, int width, int height )&lt;br /&gt;
{ &lt;br /&gt;
   return length * width * height;&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;11050100&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Define function to add two parameters together==&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;
 &lt;br /&gt;
 int Add (int x, int y)&lt;br /&gt;
 {&lt;br /&gt;
     std::cout &amp;lt;&amp;lt; &amp;quot;In Add(), received &amp;quot; &amp;lt;&amp;lt; x &amp;lt;&amp;lt; &amp;quot; and &amp;quot; &amp;lt;&amp;lt; y &amp;lt;&amp;lt; &amp;quot;\n&amp;quot;;&lt;br /&gt;
     return (x+y);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 int main()&lt;br /&gt;
 {&lt;br /&gt;
     std::cout &amp;lt;&amp;lt; &amp;quot;The value returned is: &amp;quot; &amp;lt;&amp;lt; Add(3,4);&lt;br /&gt;
     return 0;&lt;br /&gt;
 }&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;In Add(), received 3 and 4&lt;br /&gt;
The value returned is: 7&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Definition of function template maximum==&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::cin;&lt;br /&gt;
using std::endl;&lt;br /&gt;
&lt;br /&gt;
template &amp;lt; class T &amp;gt;  &lt;br /&gt;
T maximum( T value1, T value2, T value3 )&lt;br /&gt;
{&lt;br /&gt;
   T maximumValue = value1; &lt;br /&gt;
   if ( value2 &amp;gt; maximumValue )&lt;br /&gt;
      maximumValue = value2;&lt;br /&gt;
   if ( value3 &amp;gt; maximumValue )&lt;br /&gt;
      maximumValue = value3;&lt;br /&gt;
   return maximumValue;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
   int int1, int2, int3;&lt;br /&gt;
   int1 = 1;&lt;br /&gt;
   int2 = 2;&lt;br /&gt;
   int3 = 3;&lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;\nThe maximum integer value is: &amp;quot; &amp;lt;&amp;lt; maximum( int1, int2, int3 );&lt;br /&gt;
      &lt;br /&gt;
   double double1, double2, double3;&lt;br /&gt;
   double1 = 1.1;&lt;br /&gt;
   double2 = 2.2;&lt;br /&gt;
   double3 = 3.3;&lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;\nThe maximum double value is: &amp;quot;&amp;lt;&amp;lt; maximum( double1, double2, double3 );&lt;br /&gt;
   char char1, char2, char3;&lt;br /&gt;
   char1 = &amp;quot;a&amp;quot;;&lt;br /&gt;
   char2 = &amp;quot;b&amp;quot;;&lt;br /&gt;
   char3 = &amp;quot;c&amp;quot;;&lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;\nThe maximum character value is: &amp;quot;&amp;lt;&amp;lt; maximum( char1, char2, char3) &amp;lt;&amp;lt; endl;&lt;br /&gt;
   return 0;&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;The maximum integer value is: 3&lt;br /&gt;
The maximum double value is: 3.3&lt;br /&gt;
The maximum character value is: c&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Functions in an expression: order of evaluation==&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;
#include &amp;lt;ostream&amp;gt;&lt;br /&gt;
using namespace std;&lt;br /&gt;
int x = 1;&lt;br /&gt;
int f()&lt;br /&gt;
{&lt;br /&gt;
  x = 2;&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; &amp;quot;f()&amp;quot;;&lt;br /&gt;
  return x;&lt;br /&gt;
}&lt;br /&gt;
int g()&lt;br /&gt;
{&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; &amp;quot;g()&amp;quot;;&lt;br /&gt;
  return x;&lt;br /&gt;
}&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; f() / g() &amp;lt;&amp;lt; &amp;quot;\n&amp;quot;;&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;f()g()1&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Functions that take no arguments.==&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;
void f1(); &lt;br /&gt;
void f2( void ); &lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
   f1(); &lt;br /&gt;
   f2(); &lt;br /&gt;
   return 0; &lt;br /&gt;
} &lt;br /&gt;
void f1()&lt;br /&gt;
{&lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;f1 takes no arguments&amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
}&lt;br /&gt;
void f2( void )&lt;br /&gt;
{&lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;f2 also takes no arguments&amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;f1 takes no arguments&lt;br /&gt;
f2 also takes no arguments&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==The function call stack and activation records==&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::cin;&lt;br /&gt;
using std::cout;&lt;br /&gt;
using std::endl;&lt;br /&gt;
int f( int );&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
   int a = 10; &lt;br /&gt;
   cout &amp;lt;&amp;lt; a &amp;lt;&amp;lt; &amp;quot; fd: &amp;quot; &amp;lt;&amp;lt; f( a ) &amp;lt;&amp;lt; endl;&lt;br /&gt;
   return 0;&lt;br /&gt;
} &lt;br /&gt;
int f( int x )&lt;br /&gt;
{&lt;br /&gt;
   return x * x;&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;10 fd: 100&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==This program contains two functions: main() and f().==&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 namespace std; &lt;br /&gt;
 &lt;br /&gt;
void f(); // f&amp;quot;s protoype &lt;br /&gt;
 &lt;br /&gt;
int main() &lt;br /&gt;
{ &lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;In main()\n&amp;quot;; &lt;br /&gt;
 &lt;br /&gt;
  f(); // call f() &lt;br /&gt;
 &lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;Back in main()\n&amp;quot;; &lt;br /&gt;
 &lt;br /&gt;
  return 0; &lt;br /&gt;
} &lt;br /&gt;
 &lt;br /&gt;
// This if the function&amp;quot;s definition. &lt;br /&gt;
void f() &lt;br /&gt;
{ &lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;Inside f()\n&amp;quot;; &lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;In main()&lt;br /&gt;
Inside f()&lt;br /&gt;
Back in main()&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>