Article View: borland.public.cppbuilder.oodesign
Article #46Re: Meaning
From: Thomas Maeder [TeamB]
Date: Wed, 16 Mar 2005 16:08
Date: Wed, 16 Mar 2005 16:08
44 lines
2321 bytes
2321 bytes
Shannon Peterson <speterson@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.
Technical Details
Message-ID:
<m2wts74lq4.fsf@madbox2.local>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!diablo.voicenet.com!38.119.100.83.MISMATCH!news-out.nntp.be!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mailReferences:
<423855ca@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10db1e,731abaf2ddfa2fb1
X-Google-Attributes: gid10db1e,public
X-Google-Language: ENGLISH,ASCII-7-bit
Newsgroups: borland.public.cppbuilder.oodesign
Subject: Re: Meaning
References: <423855ca@newsgroups.borland.com>
From: maeder@glue.ch (Thomas Maeder [TeamB])
Organization: TeamB
X-Face: ":yn4zt^A_dn>6~{YJmu^B\'4w)e:apPM\VC=Dvf&*tASxX9|BYczkFd$xr.$vNSZ[3Uobr p]c4\+\l){!WQI.$]veP({HLd;CDYH?iN
Date: Wed, 16 Mar 2005 17:08:35 +0100
Message-ID: <m2wts74lq4.fsf@madbox2.local>
User-Agent: Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Jumbo Shrimp, linux)
Cancel-Lock: sha1:fCkhBWLWU90AUxD1ef58MeOwdks=
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
NNTP-Posting-Host: 80.218.114.55
X-Trace: newsgroups.borland.com 1110989318 80.218.114.55 (16 Mar 2005 08:08:38 -0800)
Lines: 44
X-Authenticated-User: tmaeder
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!diablo.voicenet.com!38.119.100.83.MISMATCH!news-out.nntp.be!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail