Operator definition doesn't return *this?

I was making a vector class for fun and when I made the = operator function, the compiler doesn't require me to add return *this; to be valid? Is this standard or a compiler thing (VSC++ 2008 express)?
1
2
3
Vec2f& operator=(const Vec2f& avec){ 
	x = avec.x; y = avec.y; 
}



Weird! It was the same for the Vec3f definition, but when I got to do the Vec4f function it generated a compilation error!
1
2
3
Vec4f& operator=(const Vec4f& avec){ 
	x = avec.x; y = avec.y; z = avec.z; w = avec.w;
}
I don't know why but some compilers won't complain if you don't return a value from a function. This is a problem because then what the compiler returns is undefined (which is especially dangerous because you're returning a reference.

So yeah, you should definitely be returning something here.
Topic archived. No new replies allowed.