You asked: Why does c1 remain blank??
The answer is that the assignment operator does not modify the object itself. Here's your code:
grade grade::operator=(grade cpy)
{
grade newer=cpy; //Calls the copy constructor as expected
return cpy; //No error but blank value is returned to the LHS variable.
}
The method returns a copy of the input parameter cpy
but does not modify the current instance. When this method is executing, *this
is the "LHS variable", and it's not being modified at all. Within this method (operator overload, you need to actually modify the member variables of the current instance!