What’s the ampersand for when used after class name like ostream& operator

In that case you are returning a reference to an ostream object. Strictly thinking of ampersand as “address of” will not always work for you. Here’s some info from C++ FAQ Lite on references. As far as const goes, const correctness is very important in C++ type safety and something you’ll want to do as … Read more

When to use addressof(x) instead of &x?

You use std::addressof when you have to. Sadly, “when you have to” includes anytime you are working in template code and want to turn a variable of unknown type T or T& into an honest-to-God pointer to that variable’s memory. Because the C++ committee foolishly allowed the overloading of the reference operator (to little legitimate … Read more