|
|
|
|
J'explique:
J'ai une classe POLYNOME qui a comme seul attribut un tableau de coefficient TABCOEFF
Je dois surcharger l'opérateur + ( avec 2 objets de ma classe
TPOLYNOME operator + (TPOLYNOME &P,TPOLYNOME Q)
P.TABCOEFF[i]
P.GETTABCOEFF(i)
Dans le point h:
class TPOLYNOME
{
private:
double TABCOEFF[];
public:
TPOLYNOME();
TPOLYNOME(const TPOLYNOME &_POLYNOME);
~TPOLYNOME();
double GETTABCOEFF(int indice)const;
TPOLYNOME operator [](int index);
friend ostream& operator << (ostream &o, TPOLYNOME &_POLYNOME);
friend TPOLYNOME operator + (const TPOLYNOME &P,TPOLYNOME &Q);
};
dans le .cpp double TPOLYNOME::GETTABCOEFF(int _indice)const
{
return TABCOEFF[_indice];
}
/*TPOLYNOME operator[](int index)
{
return TABCOEFF[index];
}//fin operator []
*/
ostream& operator << (ostream &o, TPOLYNOME &_POLYNOME)
{
for (int i=MAX;i>0;i--)
{
o<<_POLYNOME.TABCOEFF[i]<<" x^"<<i;
}
//return 0;
}
TPOLYNOME operator + (TPOLYNOME &P,TPOLYNOME Q)
{
for (int i=0;i<MAX;i++)
{
P.GETTABCOEFF(i) += Q.GETTABCOEFF(i);
}
}
dc voilà le code avec mes opérateurs [] et + qui ne fonctionne pas |