The program below compiles (with gcc), but should it? I would have thought that V1(1.0) created below is a constant, and so a non const method could not be invoked on it.
class V{
double v;
public:
V(double v1){ v = v1;}
void clear(){ v = 0;}
};
int main(){
V(1.0).clear();
}
Compare this to a function "void f(int &t){}" which cannot be called as "f(1)", because 1 is a constant which cannot be a value for a non-const reference t.