473,396 Members | 2,129 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

line starting with ::

Hi,

I'm learning C++, and came accross the following code.
Could someone explain me why there is a line starting with :: ?

Thanks,

Andre

ModuleA::_TAO_Services_Remote_Proxy_Broker *
ModuleA::_TAO_Services_Remote_Proxy_Broker::the_TA O_Services_Remote_Proxy_Broker
(void)
{
static ::ModuleA::_TAO_Services_Remote_Proxy_Broker
remote_proxy_broker;
return &remote_proxy_broker;
}

Jul 23 '05 #1
2 1421
si******@yahoo.com wrote in
news:11**********************@o13g2000cwo.googlegr oups.com:
Hi,

I'm learning C++, and came accross the following code.
Could someone explain me why there is a line starting with :: ?

Thanks,

Andre

ModuleA::_TAO_Services_Remote_Proxy_Broker *
ModuleA::_TAO_Services_Remote_Proxy_Broker::the_TA O_Services_Remote_Pro
xy_Broker (void)
{
static ::ModuleA::_TAO_Services_Remote_Proxy_Broker
remote_proxy_broker;
return &remote_proxy_broker;
}


:: would be referring to the global namespace (as opposed to std::, for
example).

So.. If you had:

namespace MySpace
{
int open(char * name, int flags);
}

using MySpace::open;
When you try to call

open("filename", O_RDONLY);

it may be ambiguous which you mean. However, if you use:

::open("filename", O_RDONLY);

You are explicitly stating that you want the open() that's in the global
namespace (probably supplied by your compiler), instead of the open()
that's in your MySpace namespace.

Alternately, if you are in a member function of a class which has another
member named open() (as declared above), the same problem comes in. If
you use the undecorated call to open, it will call the member function,
but if you use the :: decoration, the compiler knows to use the global
namespaced function.
Jul 23 '05 #2
sieg1974 wrote:
I'm learning C++, and came accross the following code.
Could someone explain me why there is a line starting with :: ?


Google for C++ scope resolution operator

--
Phlip
http://www.c2.com/cgi/wiki?ZeekLand
Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Andr? Roberge | last post by:
I want to "import and execute" a python program (input_test.py below) within another program (execute_test.py below) and "watch it" being executed. By watching it, I mean to display the file...
22
by: DraguVaso | last post by:
Hi, For my application I need the following behavior: When I press F4 the cursor has to move to the next line in my multiline textbox which begins with "0". Finding lines starting with 0 isn't...
3
by: Bob Greschke | last post by:
I've resorted to actually drawing all of the characters of the alphabet on a graph to avoid having to drag around font files. It's mostly just uppercase characters, so it's not too bad. But I...
1
by: navisingh | last post by:
I have a HTML page with a block of text encased in <code> </code>. This text is unwrapped (because of the code block). I want to write a javascript function that takes two arguments(starting...
6
by: Bryan Parkoff | last post by:
I want to know the best practice to write on both C / C++ source codes. The best practice is to ensure readable. Should left brace be after function or if on the same line or next line. For...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.