I was working on an example for this answer but I forgot to type return *this;
to conclude my assignment operator, so Val
's assignment operator looks like this:
Val& operator= (const int _a) {a = _a; b = _a + fmod(b, 1.0F);}
It seems like it shouldn't, but gcc compiles and runs this code. How is this possible? Is this like the main
function where there's an implied return
?