Bonjour à tous. J'ai besoin de votre aide car vrai débutant. ma question est en comentaire dans le code:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
#include <iostream>
#include <array>
using namespace std;
 
void mafct(array<int,5> tablo,int i);
int main()
{
    array<int,5> TABLO={1,2,3,4,5};
    mafct(TABLO,10);
    cout<<"=== Après passage par référence"<<endl;
    for(auto elem:TABLO)
    {
        cout<<elem<<endl;/* Ici je m'attend à
        ce que TABLO={11,12,13,14,15} puisque je fais
        un passage par référence*/
    }
    return 0;
}
 
void mafct(array<int,5> Tab,int i)
{
    for(auto elem:Tab)
    {
        elem +=i;
        cout<<elem<<endl;
    }
}
Je n'arrive pas à localiser mon erreur