Q on name hiding
Thu Sep 14 04:57:00 GMT 2000
I tried to compile the foll. piece of code on my Redhat Linux release 6.2 Kernel Ver 2.2.14-5.0 using g++;
g++ version is...
void foo( char y)
cout << "In Base class, foo(char) fn" << endl;
class D : public B
void foo( int d )
cout << "In Derived class, foo( int) fn " << endl;
d.foo( 'A' );
I am basically using the statement "using B::foo", in order to bring the base class version of foo( char ) in the derived scope, and to avoid name hiding, BUT i get the foll. error, can some one help!
tp.cc:21: cannot adjust access to `void B::foo(char)' in `class D'
tp.cc:17: because of local method `void D::foo(int)' with same name
The whole purpose of this is to get access to foo( char ), but the error seems to be neglecting the overloading concept of C++ as it just goes on the basis of name and hence rejects the overloaded version of foo.
More information about the Gcc-help