A<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://www.cppe.ru/index.php?action=history&amp;feed=atom&amp;title=C%2B%2B%2FFunction%2FFunction_Overloaded</id>
		<title>C++/Function/Function Overloaded - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://www.cppe.ru/index.php?action=history&amp;feed=atom&amp;title=C%2B%2B%2FFunction%2FFunction_Overloaded"/>
		<link rel="alternate" type="text/html" href="http://www.cppe.ru/index.php?title=C%2B%2B/Function/Function_Overloaded&amp;action=history"/>
		<updated>2026-04-18T18:08:45Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://www.cppe.ru/index.php?title=C%2B%2B/Function/Function_Overloaded&amp;diff=1571&amp;oldid=prev</id>
		<title> в 14:21, 25 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://www.cppe.ru/index.php?title=C%2B%2B/Function/Function_Overloaded&amp;diff=1571&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://www.cppe.ru/index.php?title=C%2B%2B/Function/Function_Overloaded&amp;diff=1572&amp;oldid=prev</id>
		<title>Admin: 1 версия:&amp;#32;Импорт контента...</title>
		<link rel="alternate" type="text/html" href="http://www.cppe.ru/index.php?title=C%2B%2B/Function/Function_Overloaded&amp;diff=1572&amp;oldid=prev"/>
				<updated>2010-05-25T10:27:24Z</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;==Compute area of a rectangle using overloaded functions.==&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;
&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
using namespace std;&lt;br /&gt;
double rect_area(double length, double width)&lt;br /&gt;
{&lt;br /&gt;
  return length * width;&lt;br /&gt;
}&lt;br /&gt;
double rect_area(double length)&lt;br /&gt;
{&lt;br /&gt;
  return length * length;&lt;br /&gt;
}&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
  cout  &amp;lt;&amp;lt; &amp;quot;10 x 5.8 rectangle has area: &amp;quot;;&lt;br /&gt;
  cout &amp;lt;&amp;lt; rect_area(10.0, 5.8) &amp;lt;&amp;lt; &amp;quot;\n&amp;quot;;&lt;br /&gt;
  cout  &amp;lt;&amp;lt; &amp;quot;10 x 10 square has area: &amp;quot;;&lt;br /&gt;
  cout &amp;lt;&amp;lt; rect_area(10.0) &amp;lt;&amp;lt; &amp;quot;\n&amp;quot;;&lt;br /&gt;
  return 0;&lt;br /&gt;
}&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;
==Create three functions called prompt( ) that perform this task for data of types int, double, and long==&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 prompt(char *str, int *i);  &lt;br /&gt;
void prompt(char *str, double *d);  &lt;br /&gt;
void prompt(char *str, long *l);  &lt;br /&gt;
     &lt;br /&gt;
int main(void){  &lt;br /&gt;
  int i;  &lt;br /&gt;
  double d;  &lt;br /&gt;
  long l;  &lt;br /&gt;
     &lt;br /&gt;
  prompt(&amp;quot;Enter an integer: &amp;quot;, &amp;amp;i);  &lt;br /&gt;
  prompt(&amp;quot;Enter a double: &amp;quot;, &amp;amp;d);  &lt;br /&gt;
  prompt(&amp;quot;Enter a long: &amp;quot;, &amp;amp;l);  &lt;br /&gt;
     &lt;br /&gt;
  cout &amp;lt;&amp;lt; i &amp;lt;&amp;lt; &amp;quot; &amp;quot; &amp;lt;&amp;lt; d &amp;lt;&amp;lt; &amp;quot; &amp;quot; &amp;lt;&amp;lt; l;  &lt;br /&gt;
     &lt;br /&gt;
  return 0;  &lt;br /&gt;
}  &lt;br /&gt;
     &lt;br /&gt;
void prompt(char *str, int *i)  &lt;br /&gt;
{  &lt;br /&gt;
  cout &amp;lt;&amp;lt; str;  &lt;br /&gt;
  cin &amp;gt;&amp;gt; *i;  &lt;br /&gt;
}  &lt;br /&gt;
     &lt;br /&gt;
void prompt(char *str, double *d)  &lt;br /&gt;
{  &lt;br /&gt;
  cout &amp;lt;&amp;lt; str;  &lt;br /&gt;
  cin &amp;gt;&amp;gt; *d;  &lt;br /&gt;
}  &lt;br /&gt;
     &lt;br /&gt;
void prompt(char *str, long *l)  &lt;br /&gt;
{  &lt;br /&gt;
  cout &amp;lt;&amp;lt; str;  &lt;br /&gt;
  cin &amp;gt;&amp;gt; *l;  &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 overloading between int and string type==&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;
int triple(int number);&lt;br /&gt;
string triple(string text);&lt;br /&gt;
int main(){&lt;br /&gt;
    cout &amp;lt;&amp;lt; &amp;quot;Tripling 5: &amp;quot; &amp;lt;&amp;lt; triple(5) &amp;lt;&amp;lt; &amp;quot;\n\n&amp;quot;;&lt;br /&gt;
    cout &amp;lt;&amp;lt; &amp;quot;Tripling &amp;quot;gamer&amp;quot;: &amp;quot; &amp;lt;&amp;lt; triple(&amp;quot;gamer&amp;quot;);&lt;br /&gt;
    return 0;&lt;br /&gt;
}&lt;br /&gt;
int triple(int number){&lt;br /&gt;
    return (number * 3);&lt;br /&gt;
}&lt;br /&gt;
string triple(string text){&lt;br /&gt;
    return (text + text + text);&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;
==Functions differ in number of 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;
using namespace std;&lt;br /&gt;
int myFunction(int i);       &lt;br /&gt;
int myFunction(int i, int j);&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
  cout &amp;lt;&amp;lt; myFunction(10) &amp;lt;&amp;lt; &amp;quot; &amp;quot;; // calls myFunction(int i)&lt;br /&gt;
  cout &amp;lt;&amp;lt; myFunction(4, 5);      // calls myFunction(int i, int j)&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
int myFunction(int i)&lt;br /&gt;
{&lt;br /&gt;
  return i;&lt;br /&gt;
}&lt;br /&gt;
int myFunction(int i, int j)&lt;br /&gt;
{&lt;br /&gt;
  return i*j;&lt;br /&gt;
}&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;
==Overload abs() three ways==&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;
&lt;br /&gt;
int abs(int n);&lt;br /&gt;
double abs(double n);&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;Absolute value of -10: &amp;quot; &amp;lt;&amp;lt; abs(-10) &amp;lt;&amp;lt; endl;&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;Absolute value of -10.01: &amp;quot; &amp;lt;&amp;lt; abs(-10.01) &amp;lt;&amp;lt; endl;&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
int abs(int n)&lt;br /&gt;
{&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;In integer abs()\n&amp;quot;;&lt;br /&gt;
  return n&amp;lt;0 ? -n : n;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
double abs(double n)&lt;br /&gt;
{&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;In double abs()\n&amp;quot;;&lt;br /&gt;
  return n&amp;lt;0 ? -n : n;&lt;br /&gt;
}&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;
==Overload function: int and float==&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;
int difference(int a, int b)&lt;br /&gt;
{&lt;br /&gt;
  return a-b;&lt;br /&gt;
}&lt;br /&gt;
float difference(float a, float b)&lt;br /&gt;
{&lt;br /&gt;
  return a-b;&lt;br /&gt;
}&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
  int (*p1)(int, int);&lt;br /&gt;
  float (*p2)(float, float);&lt;br /&gt;
  p1 = difference; // address of difference(int, int)&lt;br /&gt;
  p2 = difference; // address of difference(float, float);&lt;br /&gt;
  cout &amp;lt;&amp;lt; p1(10, 5) &amp;lt;&amp;lt; &amp;quot; &amp;quot;;&lt;br /&gt;
  cout &amp;lt;&amp;lt; p2(10.5, 8.9) &amp;lt;&amp;lt; &amp;quot;\n&amp;quot;;&lt;br /&gt;
  return 0;&lt;br /&gt;
}&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;
==Overload function: int and long==&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;
int rotate(int i);&lt;br /&gt;
long rotate(long i);&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
  int a;&lt;br /&gt;
  long b;&lt;br /&gt;
  a = 0x8000;&lt;br /&gt;
  b = 8;&lt;br /&gt;
  cout  &amp;lt;&amp;lt; rotate(a);&lt;br /&gt;
  cout &amp;lt;&amp;lt; endl;&lt;br /&gt;
  cout &amp;lt;&amp;lt; rotate(b);&lt;br /&gt;
  &lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
int rotate(int i)&lt;br /&gt;
{&lt;br /&gt;
  int x;&lt;br /&gt;
 &lt;br /&gt;
  if(i &amp;amp; 0x8000) x = 1;&lt;br /&gt;
  else x = 0;&lt;br /&gt;
  i = i &amp;lt;&amp;lt; 1;&lt;br /&gt;
  i += x;&lt;br /&gt;
  return i;&lt;br /&gt;
}&lt;br /&gt;
long rotate(long i)&lt;br /&gt;
{&lt;br /&gt;
  int x;&lt;br /&gt;
 &lt;br /&gt;
  if(i &amp;amp; 0x80000000) x = 1;&lt;br /&gt;
  else x = 0;&lt;br /&gt;
  i = i &amp;lt;&amp;lt; 1;&lt;br /&gt;
  i += x;&lt;br /&gt;
  return i;&lt;br /&gt;
}&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;
==Overload function to accept integer or char * argument==&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 sleep(int n);&lt;br /&gt;
void sleep(char *n);&lt;br /&gt;
#define DELAY 100000&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;.&amp;quot;;&lt;br /&gt;
  sleep(3);&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;.&amp;quot;;&lt;br /&gt;
  sleep(&amp;quot;2&amp;quot;);&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;.&amp;quot;;&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
// Sleep() with integer argument.&lt;br /&gt;
void sleep(int n)&lt;br /&gt;
{&lt;br /&gt;
  long i;&lt;br /&gt;
  for( ; n; n--)&lt;br /&gt;
    for(i = 0; i &amp;lt;DELAY; i++) ;&lt;br /&gt;
}&lt;br /&gt;
// Sleep() with char * argument.&lt;br /&gt;
void sleep(char *n)&lt;br /&gt;
{&lt;br /&gt;
  long i;&lt;br /&gt;
  int j;&lt;br /&gt;
  j = atoi(n);&lt;br /&gt;
  for( ; j; j--)&lt;br /&gt;
    for(i = 0; i &amp;lt;DELAY; 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;
==Overload the min() 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;cctype&amp;gt;&lt;br /&gt;
using namespace std;&lt;br /&gt;
char min(char a, char b);&lt;br /&gt;
int min(int a, int b);&lt;br /&gt;
double min(double a, double b);&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;Min is: &amp;quot; &amp;lt;&amp;lt; min(&amp;quot;x&amp;quot;, &amp;quot;a&amp;quot;) &amp;lt;&amp;lt; endl;&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;Min is: &amp;quot; &amp;lt;&amp;lt; min(10, 20) &amp;lt;&amp;lt; endl;&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;Min is: &amp;quot; &amp;lt;&amp;lt; min(0.2234, 99.2) &amp;lt;&amp;lt; endl;&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
// min() for chars&lt;br /&gt;
char min(char a, char b)&lt;br /&gt;
{&lt;br /&gt;
  return tolower(a)&amp;lt;tolower(b) ? a : b;&lt;br /&gt;
}&lt;br /&gt;
// min() for ints&lt;br /&gt;
int min(int a, int b)&lt;br /&gt;
{&lt;br /&gt;
  return a&amp;lt;b ? a : b;&lt;br /&gt;
}&lt;br /&gt;
// min() for doubles&lt;br /&gt;
double min(double a, double b)&lt;br /&gt;
{&lt;br /&gt;
  return a&amp;lt;b ? a : b;&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>