CELEBRATE EARTH WEEK
Save 70% on video training and simulators now through April 27*—use code EARTH. Shop now.
The syntax for instantiating a local automatic object is almost identical to that of a function declaration. This similarity is common source of mistakes.
Consider the following pair of declarations:
g is a function that takes no arguments and returns a string by value. In spite of the superficial syntactic similarity, h denotes a different entity, namely a string object whose name is h.
The same confusion occurs with static declarations:
static string g();
static string h;
In this example, g is a static function that returns a (nonstatic) string object by value. This function has internal linkage, meaning it's visible only from the translation unit that declares that function. h in this example is a static string object.
Take advantage of special member promotions, everyday discounts, quick access to saved content, and more! Join Today.