In my .h I have
const CResultats & operator = (const CResultats & desResultats);
when I write this :
CResultats CResultats :: operator = (const CResultats & desResultats) const
{
}
Why is it not working? I'm new to c++... sorry if it's stupid.
In my .h I have
const CResultats & operator = (const CResultats & desResultats);
when I write this :
CResultats CResultats :: operator = (const CResultats & desResultats) const
{
}
Why is it not working? I'm new to c++... sorry if it's stupid.
Declare the operator as
CResultats & operator = (const CResultats & desResultats);
and define it as
CResultats & CResultats :: operator = (const CResultats & desResultats)
{
}
You may declare (and define) the operastor as
const CResultats & operator = (const CResultats & desResultats);
However semantically it is an invalid declaration.
This:
const CResultats & operator = (const CResultats & desResultats);
Is a declaration of a function which takes a CResultats by const-reference, and returns a CRFesultats by const-reference.  The method itself is not const.
But this:
CResultats CResultats :: operator = (const CResultats & desResultats) const
Is a function definition for a const function which takes a CResultats by const-reference, and returns a CResultats by-value.  
Those are two different things in two ways:
If you want to definition to match the declaration, then you must change the definition to:
const CResultats & CResultats::operator = (const CResultats & desResultats)
{
  // ...
}
When you write "this", it's not "valid" because it doesn't fit the signature; it's different for the compiler
A member operator (function) having const at the end operates at const objects, as simple as that. In this case it doesn't make any sense, though, because the only sensible operation of this operator is modifying the object.