Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > member function with no class name specified

Reply
Thread Tools

member function with no class name specified

 
 
John Goche
Guest
Posts: n/a
 
      11-16-2006
Hello,

I have come across the following directive but I don't see a class
name specified in front of the ::Check function. Does anyone
know what this means and how the directive is supposed to work?

#define TEST2(aValue, aExpected) ::Check(aValue, aExpected, __LINE__)

Thanks,

JG

 
Reply With Quote
 
 
 
 
mlimber
Guest
Posts: n/a
 
      11-16-2006
John Goche wrote:
> Hello,
>
> I have come across the following directive but I don't see a class
> name specified in front of the ::Check function. Does anyone
> know what this means and how the directive is supposed to work?
>
> #define TEST2(aValue, aExpected) ::Check(aValue, aExpected, __LINE__)


::Check is a function in the global namespace.

Cheers! --M

 
Reply With Quote
 
 
 
 
VJ
Guest
Posts: n/a
 
      11-16-2006
mlimber wrote:
> John Goche wrote:
>
>>Hello,
>>
>>I have come across the following directive but I don't see a class
>>name specified in front of the ::Check function. Does anyone
>>know what this means and how the directive is supposed to work?
>>
>>#define TEST2(aValue, aExpected) ::Check(aValue, aExpected, __LINE__)

>
>
> ::Check is a function in the global namespace.
>


Can it be used for functions in the nameless namespace? Or is it more
for global functions?

For example:

#include <iostream>
using namespace std;

namespace
{
void f()
{
cout<<"222222222222"<<endl;
}
}

int main()
{
::f();
}

This will print 2's
 
Reply With Quote
 
Victor Bazarov
Guest
Posts: n/a
 
      11-16-2006
VJ wrote:
> mlimber wrote:
>> John Goche wrote:
>>
>>> Hello,
>>>
>>> I have come across the following directive but I don't see a class
>>> name specified in front of the ::Check function. Does anyone
>>> know what this means and how the directive is supposed to work?
>>>
>>> #define TEST2(aValue, aExpected) ::Check(aValue, aExpected,
>>> __LINE__)

>>
>>
>>>> Check is a function in the global namespace.

>>

>
> Can it be used for functions in the nameless namespace? Or is it more
> for global functions?


Yes, it can. Unnamed/nameless/anonymous namespace names are inserted
into the scope in which that namespace appears. The way anonymous
namespace

// some scope
namespace {
// some names declared
}

behaves is similar to

// some scope
namespace SomeWeIrD_and_UNIQUEnaME {}
using namespace SomeWeIrD_and_UNIQUEnaME;
namespace SomeWeIrD_and_UNIQUEnaME {
// some names declared
}

(see 7.3.1.1/1); only the weird and unique name is different for
every translation unit and is *not* available to the programmer.

>
> For example:
>
> #include <iostream>
> using namespace std;
>
> namespace
> {
> void f()
> {
> cout<<"222222222222"<<endl;
> }
> }
>
> int main()
> {
> ::f();
> }
>
> This will print 2's


.... As it should.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
What is the correct grammar to make a function call by using static member data which is a pointer to a ordinary class member function? zaeminkr@gmail.com C++ 3 07-06-2007 12:50 PM
member function with no class name specified jackgoche@googlemail.com C++ 2 11-16-2006 04:59 PM
Nested Class, Member Class, Inner Class, Local Class, Anonymous Class E11 Java 1 10-12-2005 03:34 PM
parse error in gcc but success in vc.net, call a non_template class's template member function from a template class's member function! ken C++ 2 06-28-2005 06:57 AM
Pointer-to-member-function pointing to a member function of an inherited class akiriwas@gmail.com C++ 12 02-11-2005 05:15 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57