namespaces composition and selection
Anitha Boyapati
anithab@sankhya.com
Tue Oct 24 06:41:00 GMT 2006
Hi,
Here is the sample program I have written :
------------------------------------------------------------
#include "user_defined.h"
//using namespace user_defined;
int main()
{
user_defined::base *b=new user_defined::base();
b->display();
user_defined::base *y = new user_defined::base();
y->display();
}
---------------------------------------------------------
file : user_defined.h
#include "mine.h"
#include "yours.h"
namespace user_defined {
using namespace mine; //use all from mine
using namespace yours; //use all from yours
using yours::base; //resolve conflict for base in favour of yours
};
-------------------------------------------------------------
Both mine::base and yours::base exists.(base is again another class)
and as commented yours::base is favoured when there is a conflict.
The problem I encountered is, I cannot directly use any decalaration
related to base without scope resolution(user_defined::base).
What I want is : Can I not make it work with
using namespace user_defined;
alone(the part has been commented ).If comments are removed and scope
resolution is also removed, the compiler complaines of ambigous base
class type.
Can somebody pull me out?
[I am trying this example with gcc version 3.2.3 20030502.The example
is related to c++ Programming language by Stroustrup]
Thanks in advance.
--
Regards,
Anitha B.
More information about the Gcc-help
mailing list