|
|
Регистрация Восстановить пароль |
Повторная активизация e-mail |
Регистрация | Задать вопрос |
Заплачу за решение |
Новые сообщения |
Сообщения за день |
Расширенный поиск |
Правила |
Всё прочитано |
|
Опции темы | Поиск в этой теме |
10.01.2013, 23:56 | #1 |
Пользователь
Регистрация: 18.12.2011
Сообщений: 30
|
перегрузка функции..
(17)
С помощью механизма перегрузки функций реализовать функции для вывода на экран (первый параметр – тип выводимого значения (самостоятельно разработать систему обозначений )). есть впринципе, готовая, но выдаёт ошибки, исправьте пожалуйста по мере возможности... #include "string.h" #include "iostream" #include "conio.h" #include "stdlib.h" #include "stdio.h" int max(int a,int b,int c); char max(char st[20],char st1[20],char st2[20],int a,int b,int c); char max(char st[20],int chislo,int a); char max(int chislo,char st[20],int a); int max(int a,int b,int c) { cout<<"Vvedite a"<<endl; cin>>a; cout<<"Vvedite b"<<endl; cin>>b; cout<<"Vvedite c"<<endl; cin>>c; if ((a>b)&&(a>c)) { cout<<"max a="; return a;} else if ((b>a)&&(b>c)) {cout<<"max b"; return b;} else if ((c>a)&&(c>b)) { cout<<"max c"; return c;} } char max(char st[20],char st1[20],char st2[20],int a,int b,int c) { cout<<"Vvedite stroky 1:"<<endl; cin>>st; cout<<"Vvedite stroky 2:"<<endl; cin>>st1; cout<<"Vvedite stroky3:"<<endl; cin>>st2; a=strlen(st); b=strlen(st1); c=strlen(st2); if ((a>b)&&(a>c)) { cout<<"Pervaya stroka bolshe"; return 0; } else if ((b>a)&&(b>c)) { cout<<"Vtoraya stroka bolshe"; return 0; } else if ((c>a)&&(c>b)) { cout<<"Tret'ya stroka bolshe"; return 0; } } char max(char st[20],int chislo,int a) { cout<<"Vvedite stroky:"<<endl; cin>>st; cout<<"Vvedite chislo:"<<endl; cin>>chislo; a=strlen(st); if (a>chislo) { cout<<"Stroka bolshe"; return 0;} else cout<<"Chislo bolshe"; return chislo; } char max(int chislo,char st[20],int a) { cout<<"Vvedite chislo"<<endl; cin>>chislo; cout<<"Vvedite stroky"<<endl; cin>>st; a=strlen(st); if (chislo>a) { cout<<"Chislo bolshe"; return chislo; } else cout<<"Stroka bolshe"; return 0; } void main() { int a,b,c,chislo; char st[20],st1[20],st2[20]; max(a,b,c); max(st,st1,st2,a,b,c); max(st,chislo,a); max(chislo,st,a); getch(); } |
Похожие темы | ||||
Тема | Автор | Раздел | Ответов | Последнее сообщение |
перегрузка функции на С++ | erfo | Помощь студентам | 0 | 23.05.2012 18:32 |
Перегрузка функции Delphi | xxAlexxx | Помощь студентам | 2 | 23.04.2012 03:49 |
Перегрузка функции.С++ | jagger | Помощь студентам | 8 | 11.11.2010 22:27 |
Перегрузка функции.. (выдаёт ошибку) | tipilat | Помощь студентам | 13 | 30.03.2010 19:19 |
Перегрузка функции в С++ | Vultar | Помощь студентам | 7 | 19.11.2009 13:12 |