Incrémenter une variable par référence dans une méthode
Bonjour,
j'ai un petit soucis ce qui concerne d'après que je croie c'est un problème de pointeur et j'arrive pas a le résoudre
Code:
1 2 3 4 5 6 7 8 9 10 11 12
|
int main()
{
tableau a; // tableau est une classe j'ai crée une instance
a.tab_prod = new tab_prod_fab[100]; // tab_prod est un vecteur qui contient une liste or de type tab_prod_fab
for (int i=0;i<5;i++,a.tab_prod++) //ici incrémentation ça marche a.tab_prod++
{init_prod_fab(*a.tab_prod,i);
affiche_prod_fab(*a.tab_prod);
} |
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
void init_prod_fab(tab_prod_fab &e,int cpt)
{ // ici sa marche pas l'incrémentation de a.tab_prod qui est ici e de type tab_prod_fab++
string Nomprod[5]={"Machine à Laver","cuisiniére","cafétiére","frigo","frigo samsung"};
string durefabric[5]={"13","40","14","55","33"};
int EtatStock[5]={23,12,18,25,54};
int Quantitfab[5]={0,0,0,0,0};
strcpy(e.Nom_prod,Nomprod[cpt].c_str());
strcpy(e.dure_fabric,durefabric[cpt].c_str());
e.Etat_stok=EtatStock[cpt];
e.Quantit_fab=Quantitfab[cpt];
} |
Code:
1 2 3 4 5 6 7 8
|
class tableau
{
public:
int i,j;
int t[20];
tab_prod_fab *tab_prod;
} |
Code:
1 2 3 4 5 6 7 8 9
|
//voila ma structure
struct tab_prod_fab
{
char Nom_prod[30];
char dure_fabric[30]; // le nom du produit et durré de fabrication du produit
int Etat_stok; // nombre de produit en stock
int Quantit_fab; //Quantité à fabriqué ce qu'il reste a fabriqué pour le client (quantité demandé état de stock)
}; |
le probléme est que j'arrive pas a incrémenté la variable de type tableau a.tab_prod++ dans la méthode void init_prod_fab(tab_prod_fab &e,int cpt)
Merci d'avance de votre attention