Hi there.
Given the following code, why is class B::A used at point //2 and not
class ::A ?
Does inheriting a class in a namespace put the names of that namespace into
the "name pool" used for unqualified lookup?
Where do I find that in the "Holy Standard" ?
Thanks,
Stefan
// -----SNIP-----
#include <iostream>
class A
{
public:
void print()
{
std::cout << "class ::A" << std::endl;
}
};
namespace B
{
class A
{
public:
void print()
{
std::cout << "class B::A" << std::endl;
};
};
}
template <typename Tclass C
{
public:
T object;
};
class D : public B::A //1
{
public:
void call_print()
{
C<Ac; //2
c.object.print( );
};
};
int main()
{
D* test = new D;
test->call_print() ;
delete test;
return 0;
}
// -----SNAP-----
--
Stefan Naewe stefan dot naewe at atlas-elektronik dot com
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please http://www.expita.com/nomime.html 2 1534
On 8/19/2008 12:18 PM, Stefan Naewe wrote:
Hi there.
Given the following code, why is class B::A used at point //2 and not
class ::A ?
Does inheriting a class in a namespace put the names of that namespace into
the "name pool" used for unqualified lookup?
Where do I find that in the "Holy Standard" ?
Thanks,
Stefan
Anyone?
// -----SNIP-----
#include <iostream>
class A
{
public:
void print()
{
std::cout << "class ::A" << std::endl;
}
};
namespace B
{
class A
{
public:
void print()
{
std::cout << "class B::A" << std::endl;
};
};
}
template <typename Tclass C
{
public:
T object;
};
class D : public B::A //1
{
public:
void call_print()
{
C<Ac; //2
c.object.print( );
};
};
int main()
{
D* test = new D;
test->call_print() ;
delete test;
return 0;
}
// -----SNAP-----
--
Stefan Naewe stefan dot naewe at atlas-elektronik dot com
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please http://www.expita.com/nomime.html
Stefan Naewe wrote:
On 8/19/2008 12:18 PM, Stefan Naewe wrote:
>Hi there.
Given the following code, why is class B::A used at point //2 and not class ::A ? Does inheriting a class in a namespace put the names of that namespace into the "name pool" used for unqualified lookup? Where do I find that in the "Holy Standard" ?
Thanks, Stefan
Anyone?
Well, B::A is a base class of D, so it is "obviously" visible inside
class D's functions. Therefore there is no need to go looking for any
global As elsewhere.
If I could quote chapter and verse, I would have replied with that the
first time. :-)
It is probably a combination of several rules, including "class name
injection" and other nasties.
Bo Persson
>
>// -----SNIP----- #include <iostream>
class A { public: void print() { std::cout << "class ::A" << std::endl; } };
namespace B { class A { public: void print() { std::cout << "class B::A" << std::endl; }; }; }
template <typename Tclass C { public: T object; };
class D : public B::A //1 { public: void call_print() { C<Ac; //2 c.object.print( ); }; };
int main() { D* test = new D; test->call_print() ; delete test; return 0; } // -----SNAP-----
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Fritz Bosch |
last post by:
Hi experts
Is is possible to import/manipulate a module such that
I can supply its __dict__?
I want to supply my own dict subclass object to be filled
by the import, e.g. a class like:
>>> class MyModuleDict(dict):
.... def __setitem__(self,name,val):
|
by: Xavier Decoret |
last post by:
The following code does not compoile with gcc-3.2.3
namespace dummy
{
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Interface of Foo
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
class Foo
{
public:
|
by: Stefan Siegl |
last post by:
Hello,
I am trying to learn XSLT to use it in another project. I start reading
the book "Java and XSLT" and tried the examples and they are went quite
fine (how suprising *g*).
Then I tried to adopt these examples to my files. Unfortunately I did
not work even though the styleSheet is very simple. Perhaps you can help
me with it.
|
by: Bernd Fuhrmann |
last post by:
Hi!
I just tried to write a little program, but GCC (Mingw 3.3.1) refused to
compile it. So I'd like to know if there's something wrong with my code
or if it is a bug in GCC.
---snip---
namespace Namespace {}
template <class TSomeType>
|
by: Petter Reinholdtsen |
last post by:
I ran into a problem on HP-UX 11.00 the other day, where it refused to
compile a program using 'using namespace std;' at the top. The reason
seem to be that the compiler refuses to accept 'using namespace std;'
unless the std namespace was declared first.
This triggered my curiosity, and I tried to find out what the ANSI C++
standard had to say about this. I'm unable to find a conclusion, and
hope someone here have a clue to spare.
...
| |
by: Alfonso Morra |
last post by:
I have written a class, and several of it's methods are function
templates. When I compiled the code, I realized that I had made some
typos in the code - but the compiler seemed to skip right over these
obvious errors. I gre suspicious and enterred XXX in one of the function
templates - and the compiler succesfully compile the code (obviously
completely skipped my templated functions).
I am using VC 7.1 Is this a "bug", (highly unlikely,...
|
by: Dilip |
last post by:
How did the Koenig lookup come to be associated with templates?
If I have something like this: (no template code)
namespace X
{
enum E { e1 };
void f(E) { }
}
|
by: Andrey Tarasevich |
last post by:
Hello
Consider the following code fragment
namespace N {
struct S {
void foo();
};
}
|
by: JohnQ |
last post by:
Well apparently not since one can step thru template code with a debugger.
But if I was willing to make the concession on debugging, templates would be
strictly a precompiler thing? I have a feeling the answer I'm going to get
back will be "no, because templates have taken on a life of their own since
their original conception and now also affect compiler implementation"
(read: not good, IMO.
John
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| | |