Use of Double Colon Operator

K

KevinSimonson

Last Saturday I posted this to "comp.lang.c":

=I had a job interview yesterday in which I was asked to find as many
=bugs as possible in a section of C code. Part of the code said:
=
=struct Node
={ struct Node* next;
= int data;
=
=};
=
=and later a variable was declared
=
=struct Node** xyz;
=
=and later on in the code an expression included the phrase
"xyz::next"
=which as far as I could tell was the equivalent of "(*xyz)->next".
Is
=this a legal use of the "::" operator? I wasn't aware that the "::"
=operator was even _legal to use_ in C; I thought it was a C++
=operator. Any input on this would be greatly appreciated.

Is this even a legal use of the "::" operator in C++? Does
"xyz::next" in C++
mean the same as "(*xyz)->next"?

---Kevin Simonson

"You'll never get to heaven, or even to LA,
if you don't believe there's a way."
from _Why Not_
 
V

Victor Bazarov

KevinSimonson said:
Last Saturday I posted this to "comp.lang.c":

=I had a job interview yesterday in which I was asked to find as many
=bugs as possible in a section of C code. Part of the code said:
=
=struct Node
={ struct Node* next;
= int data;
=
=};
=
=and later a variable was declared
=
=struct Node** xyz;
=
=and later on in the code an expression included the phrase
"xyz::next"
=which as far as I could tell was the equivalent of "(*xyz)->next".
Is
=this a legal use of the "::" operator? I wasn't aware that the "::"
=operator was even _legal to use_ in C; I thought it was a C++
=operator. Any input on this would be greatly appreciated.

Is this even a legal use of the "::" operator in C++?

The name on the left-hand side of '::' has to be of a type or namespace.
There can be no variable name on the left-hand side of '::'.
> Does
"xyz::next" in C++
mean the same as "(*xyz)->next"?

No.

V
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top