merci pour ta reponse en fait j'essai ca comme exercice parceque ce que je veux vraiment faire c'est celui la: mais j'ai une tonne d'erreurs jarrive à afficher ni l nom ni les autres attributs de ma classe si tu peu essayer ce serai sympa.
#include<iostream>
using namespace std;
class Cproduit
{
protected:
char* nomProduit;
int* etatStock;
int* dureeFab;
int* delaiLiv;
public:
Cproduit(const char*nom, int*etat,const int*duree,const int*delai);
void setNom(const char*nom);
void setEtat( int*etat);
void setDuree(const int*duree);
void setDelai(const int*delai);
void affiche();
};
Cproduit::Cproduit(const char*nom, int*etat,const int*duree,const int*delai)
{
this->setNom(nomProduit);
this->setEtat(etatStock);
this->setDuree(dureeFab);
this->setDelai(delaiLiv);
}
void Cproduit::setNom(const char*nom)
{
if(nom)
{
this->nomProduit=new char[strlen(nom)];
strcpy(this->nomProduit,nom);
}
else
nomProduit=NULL;
}
void Cproduit::setEtat( int*etat)
{
if(etat)
{
this->etatStock=etat;
}
else this->etatStock=NULL;
}
void Cproduit::setDuree(const int*duree)
{
if(duree)
{
this->dureeFab;
}
else this->dureeFab=NULL;
}
void Cproduit::setDelai(const int*delai)
{
if(delai)
{
this->delaiLiv;
}
else this->delaiLiv=NULL;
}
void Cproduit::affiche()
{
cout<< "nomProduit:"<<this->nomProduit<<endl;
cout<< "etatStock:"<<etatStock<<endl;
cout<< "dureefab:"<<dureeFab<<endl;
cout<< "delailiv:"<<delaiLiv<<endl;
}
int main(int argc,char*argv[])
{
Cproduit nomProduit("stylo");
Cproduit etatStock(5);
nomproduit.affiche();
etatStock.affiche();

return 0;
}