Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > templates, namespace, and name lookup

Reply
Thread Tools

templates, namespace, and name lookup

 
 
Stefan Naewe
Guest
Posts: n/a
 
      08-19-2008
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 T> class C
{
public:
T object;
};

class D : public B::A //1
{
public:
void call_print()
{
C<A> c; //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
 
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
typedefs, qualified identifiers, class names and name lookup Ivan A. Kosarev C++ 0 01-13-2006 09:20 AM
print("my name is {name}, and {age}-year old {gender}", name, age, gender); =?iso-8859-1?B?bW9vcJk=?= Java 7 01-02-2006 04:39 PM
access and name lookup, surprised by this code John Harrison C++ 9 02-22-2004 07:34 AM
Default arguments, object sharing, name lookup and others Maciej Sobczak Python 5 12-23-2003 09:33 AM
Re: Urgent! how to get object name, method name and attribute name based on the strings? ding feng C++ 2 06-25-2003 01:18 PM



Advertisments