0
What's the meaning of " :: " ?
what's the meaning of "::" in this sentence i+::i%c; where i and c are Integer
3 Réponses
+ 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
+ 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 : )
0
of course
It's
int i=10;
int main (){
int i=20, c=7;
cout << i+::i%c;
return 0;