473,411 Members | 1,998 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,411 software developers and data experts.

member function with no class name specified

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

Nov 16 '06 #1
3 1525
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

Nov 16 '06 #2
VJ
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
Nov 16 '06 #3
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
Nov 16 '06 #4

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

Similar topics

9
by: Penn Markham | last post by:
Hello all, I am writing a script where I need to use the system() function to call htpasswd. I can do this just fine on the command line...works great (see attached file, test.php). When my...
9
by: Derek Hart | last post by:
I wish to execute code from a string. The string will have a function name, which will return a string: Dim a as string a = "MyFunctionName(param1, param2)" I have seen a ton of people...
24
by: Steven T. Hatton | last post by:
In the following code, at what point is S::c fully defined? #include <iostream> using std::cout; using std::endl; using std::ostream; class C { int _v;
3
by: Tran Tuan Anh | last post by:
Dear all, I am new with C++ and very confused with some features. Really appreciate if you can explain to me some of stuffs below. I define a class: class A { static A* instance = 0; };
5
by: Levent | last post by:
Hi, Why doesn't this work? (tried with gcc 3.3.3 and VC++ 7.1): #include <iostream> template<class T, unsigned N> struct Foo { void func(); }; template<class T, unsigned N>
6
by: Bill Rubin | last post by:
The following code snippet shows that VC++ 7.1 correctly compiles a static member function invocation from an Unrelated class, since this static member function is public. I expected to compile the...
2
by: jackgoche | last post by:
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...
6
by: Howard | last post by:
Hi, I have a function in three unrelated but similar classes. The code in the member functions is identical for all three classes. What I want is to make a template which defines the function,...
28
by: Jess | last post by:
Hello, It is said that if I implement a "swap" member function, then it should never throw any exception. However, if I implement "swap" non- member function, then the restriction doesn't...
15
by: akomiakov | last post by:
Is there a technical reason why one can't initialize a cost static non- integral data member in a class?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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.