[Débutant] Explication des prototypes SVP
Bonjour,
Je suis entrain de faire quelques excercices d'un livre:
Donc, premier excecice donne:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
#include <iostream>
short int z (unsigned short int x, unsigned short int y)
{
if (y == 0)
{
return -1;
}
else
{
return (x / y);
}
}
int main()
{
using std::cout;
using std::cin;
using std::endl;
int a, b, c;
cout << "Entrez deux valeurs" << endl;
cin >> a;
cin >> b;
c=z(a,b);
if (c != -1)
cout << "Le quotien est egal a: " << c << endl;
else
cout << "Erreur, division par 0 impossible!";
return 0;
} |
Donc, pas de problème pour le premier, ensuite, je commence le second:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
#include <iostream>
int fTotal (int fNombre, int fExposant);
int main()
{
using std::cout;
using std::cin;
using std::endl;
int Nombre, Exposant, Total;
cout << "Entrez deux nombres: " << endl;
cin >> Nombre;
cin >> Exposant;
Total = fTotal(Nombre, Exposant);
cout << "Total = " << Total << endl;
return 0;
}
int fTotal(int fNombre, int fExposant)
{
return fNombre + fExposant;
} |
Lors du second, j'ai du faire un prototype car le compilateur me disait que fTotal n'était pas déclaré. Certes.
J'aimerai avoir quelques explications si possible, car je ne vois vraiment pas de différence actuellement entre les 2 listings ... je suis un peu perdu.
Quand a-ton besoin de déclarer un prototype ?