Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Meaning

0 views
Skip to first unread message

Shannon Peterson

unread,
Mar 16, 2005, 10:51:28 AM3/16/05
to
I have a chunck of code and it uses code like:

AnsiString mystring = ::func(stuff() + "string");

all over the place and I was wondering if the :: is just allocating
space for data returned by the function call?

is it the same as void::Func()?

if my assumption is wrong could you please correct me.

thanks

Shannon

Thomas Maeder [TeamB]

unread,
Mar 16, 2005, 11:08:35 AM3/16/05
to
Shannon Peterson <spet...@ae-solutions.com> writes:

> AnsiString mystring = ::func(stuff() + "string");
>
> all over the place and I was wondering if the :: is just allocating
> space for data returned by the function call?

Not at all.


The expression

func("string")

means that a function named func() is to be called, and "string" is to
be passed as argument.


This sounds simple, but it's not. Because in C++, we have
overloading.

The compiler thus first has to look for functions named func in a
sequence of namespaces. As soon as one or more functions named func
have been found in a namespace, this search stops. Among the functions
found, those that can't take "string" as an argument are discarded
from the candidate functions. If this process ends up with exactly one
function, that function is called.

Prefixing func with :: changes the sequence of namespace where the
search for func is performed: func() is only looked for the global
namespace.


> is it the same as void::Func()?

No.

void::Func()

is a sytax error, while

AnsiString mystring = ::func(stuff() + "string");

is syntactically correct.

Shannon Peterson

unread,
Mar 16, 2005, 11:17:36 AM3/16/05
to
Thanks, it all makes sense now.

Shannon

0 new messages