What's the meaning of " :: " ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What's the meaning of " :: " ?

what's the meaning of "::" in this sentence i+::i%c; where i and c are Integer

1st Jan 2018, 10:17 PM
bri
bri - avatar
3 Answers
+ 4
@Bri, it appears you have two int variables declared, one in the module scope, and the other is a local variable. Then the use of :: here would be to distinguish between the two, when you type ::i you are referring the int i declared at the module scope, and when you. type just i (without ::) you are referring to the local variable (declared in main). Hth, cmiiw
2nd Jan 2018, 12:26 AM
Ipang
+ 2
@Bri, Can you post a full form of the code? a partial view of the code like this may lead to misunderstanding of the actual code intention. I am learning C++ too, but so far, from my understanding, a :: is used to explicitly declare scope addressing, e.g. when you use some type defined in a certain namespace, <namespace>::<type>, or to access a static member of a class, <class>::<member>. I may be mistaken, or misunderstood, but that's how I see it, if you have the code, or link to the code, I guess it's better to show it here, so to eliminate doubts and uncertainties : )
1st Jan 2018, 11:50 PM
Ipang
0
of course It's int i=10; int main (){ int i=20, c=7; cout << i+::i%c; return 0;
2nd Jan 2018, 12:07 AM
bri
bri - avatar