In simple terms, ::
separates names from surnames, while .
separates components from sub-components. (Note that in many languages like C#, Java, D, ...) there is no such distinction)
In your fist example, myarray
is a variable, whose size()
method refer to that particular variable.
array<int,5> myarray_a, myarray_b;
int sa=myarray_a.size();
int sb=myarray_b.size();
Will give the sizes of myarray_a
and b
respectively (not of array<int,5>
, even if -due to this particular case- all sizes will be 5)
In the second example, now() is a static
method of the class chrono::high_resolution_clock
.
It doesn't matter if you have or not a variable (and how many) of type chrono::high_resolution_clock
. That function does not refer to the variable but works the same for all variables of the same type (there is conceptually just one now
, no matter who you ask to).
Because of this, call now()
as part of a variable, of by fully qualifying its name is the same.
Note that, the size()
function of std::array
is strange: the size of std::array
is compile time defined, hence size()
could have been static as well. But std::
designers let them as member (although constexpr
, so still usable in compile time expressions) to retain the same behavior as in std::array
or other containers (where it has to be dynamic, and associated to a variable, since each size can vary during execution)