What is the return type of the built-in assignment operator?

The standard correctly defines the return type of an assignment operator. Actually, the assignment operation itself doesn’t depend on the return value – that’s why the return type isn’t straightforward to understanding. The return type is important for chaining operations. Consider the following construction: a = b = c;. This should be equal to a …

Read more

Why would code explicitly call a static method via a null pointer?

Static member functions were added into C++ in 1989, in Release 2.0 of the AT&T C++ Language System (pre-standardisation). Prior to that, the static keyword could not be used to declare static member functions, so code authors used workarounds, principally the one you have observed of indirecting a null pointer. In the Selected Readings accompanying …

Read more

Why is the dereference operator (*) also used to declare a pointer?

In The Development of the C Language, Dennis Ritchie explains his reasoning thusly: The second innovation that most clearly distinguishes C from its predecessors is this fuller type structure and especially its expression in the syntax of declarations… given an object of any type, it should be possible to describe a new object that gathers …

Read more