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
> 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