+ 1
Why the :: before size on line 22?
5 Answers
+ 7
:: is scope resolution operator. Here it is used to access global variable(size) value.
+ 5
The compilation error regarding ambiguity when the scope resolution operator is removed is due to the function size() defined under the std namespace, introduced in C++17. It returns the size of an STL like container. ( https://en.cppreference.com/w/cpp/iterator/size )
Unless there is an ambiguity, you need not use the scope resolution operator to use a global variable. But it is always better to define local variables instead, or use a namespace or class for the same.
This is why 'using namespace' statements is a bad idea.
+ 2
On code playground, if I remove :: the code does not run as it claims that the reference to size is ambiguous.
+ 1
I Know it's the scope resolution operator. Just that I once removed it and I stopped seeing special characters like "*#^..." In the password but after running it again and they appear
+ 1
Anyway thanks guys