educative.io

Educative

Trouble understanding the syntax "::tolower"

I am having a hard time, looking up on google, what leaving the namespace value blank in front of :: does.
Can someone give me a pointer?

Hi @JB_Wolverine ,

There isn’t any scope resolution operator in java, however, having :: without anything before it shows the global scope in C++.
For example

#include <iostream>
using namespace std;

int number = 10;
int main(int argc, char * args){
       int number = 20;
       cout << "Local variable: " << number << endl; // 20
       cout << "Global variable: " << ::number << endl; // 10
       return 0;
}

I hope I have answered your question. Please feel free to ask anything.