c++ - What is the meaning of :: when nothing is prefixed to it? -
this question has answer here:
i working on project involving sockets , qt. want use socket functions within sys/socket.h , not ones come qt. (this because following tutorial type stuff).
the following code:
if (connect(sock, (const struct sockaddr *) &servaddr, (socklen_t) sizeof(servaddr)) < 0){ //connect server
caused following error:
error: no matching function call 'mainwindow::connect(int&, const sockaddr*, socklen_t)'
i fixed adding :: in front of connect() so:
if (::connect(sock, (const struct sockaddr *) &servaddr, (socklen_t) sizeof(servaddr)) < 0){ //connect server
as understand can use :: prefixed namespace mean in current use? found out how fix error forum post did not explain underlying thought behind it. other tricks using :: .
it means take expression after global scope. see this answer more details.
Comments
Post a Comment